From cf8ee08b1bfb5680e2e199f3330ae93ef3a901a0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Thu, 3 Jun 2004 19:48:31 +0000 Subject: [PATCH] added tests for wx's CRT wrappers (so far only wxGetEnv,wxSetEnv) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27604 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- tests/Makefile.in | 12 ++++++-- tests/makefile.bcc | 4 +++ tests/makefile.gcc | 4 +++ tests/makefile.vc | 4 +++ tests/makefile.wat | 13 ++++++++- tests/strings/crt.cpp | 65 +++++++++++++++++++++++++++++++++++++++++++ tests/test.bkl | 1 + tests/test.dsp | 4 +++ 8 files changed, 104 insertions(+), 3 deletions(-) create mode 100644 tests/strings/crt.cpp diff --git a/tests/Makefile.in b/tests/Makefile.in index 7ec05e0780..26df18762c 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -48,6 +48,7 @@ TEST_OBJECTS = \ test_strings.o \ test_stdstrings.o \ test_unicode.o \ + test_crt.o \ test_bstream.o \ test_ffilestream.o \ test_filestream.o \ @@ -118,9 +119,13 @@ test$(EXEEXT): $(TEST_OBJECTS) data: @mkdir -p . @for f in testdata.fc; do \ - if test \( ! -s ./$$f \) -o \( $(srcdir)/$$f -nt ./$$f \) ; then \ - cp -pRf $(srcdir)/$$f . ; \ + if test ! -e ./$$f ; \ + then x=yep ; \ + else x=`find $(srcdir)/$$f -newer ./$$f -print` ; \ fi; \ + case "$$x" in ?*) \ + cp -pRf $(srcdir)/$$f . ;; \ + esac; \ done test_test.o: $(srcdir)/test.cpp @@ -159,6 +164,9 @@ test_stdstrings.o: $(srcdir)/strings/stdstrings.cpp test_unicode.o: $(srcdir)/strings/unicode.cpp $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $< +test_crt.o: $(srcdir)/strings/crt.cpp + $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $< + test_bstream.o: $(srcdir)/streams/bstream.cpp $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $< diff --git a/tests/makefile.bcc b/tests/makefile.bcc index 56ddd10a19..286725c4aa 100644 --- a/tests/makefile.bcc +++ b/tests/makefile.bcc @@ -42,6 +42,7 @@ TEST_OBJECTS = \ $(OBJS)\test_strings.obj \ $(OBJS)\test_stdstrings.obj \ $(OBJS)\test_unicode.obj \ + $(OBJS)\test_crt.obj \ $(OBJS)\test_bstream.obj \ $(OBJS)\test_ffilestream.obj \ $(OBJS)\test_filestream.obj \ @@ -206,6 +207,9 @@ $(OBJS)\test_stdstrings.obj: .\strings\stdstrings.cpp $(OBJS)\test_unicode.obj: .\strings\unicode.cpp $(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $** +$(OBJS)\test_crt.obj: .\strings\crt.cpp + $(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $** + $(OBJS)\test_bstream.obj: .\streams\bstream.cpp $(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $** diff --git a/tests/makefile.gcc b/tests/makefile.gcc index c0335b58bf..bd6e8e8364 100644 --- a/tests/makefile.gcc +++ b/tests/makefile.gcc @@ -33,6 +33,7 @@ TEST_OBJECTS = \ $(OBJS)\test_strings.o \ $(OBJS)\test_stdstrings.o \ $(OBJS)\test_unicode.o \ + $(OBJS)\test_crt.o \ $(OBJS)\test_bstream.o \ $(OBJS)\test_ffilestream.o \ $(OBJS)\test_filestream.o \ @@ -200,6 +201,9 @@ $(OBJS)\test_stdstrings.o: ./strings/stdstrings.cpp $(OBJS)\test_unicode.o: ./strings/unicode.cpp $(CXX) -c -o $@ $(TEST_CXXFLAGS) $< +$(OBJS)\test_crt.o: ./strings/crt.cpp + $(CXX) -c -o $@ $(TEST_CXXFLAGS) $< + $(OBJS)\test_bstream.o: ./streams/bstream.cpp $(CXX) -c -o $@ $(TEST_CXXFLAGS) $< diff --git a/tests/makefile.vc b/tests/makefile.vc index ba50e8d606..17fb23c438 100644 --- a/tests/makefile.vc +++ b/tests/makefile.vc @@ -35,6 +35,7 @@ TEST_OBJECTS = \ $(OBJS)\test_strings.obj \ $(OBJS)\test_stdstrings.obj \ $(OBJS)\test_unicode.obj \ + $(OBJS)\test_crt.obj \ $(OBJS)\test_bstream.obj \ $(OBJS)\test_ffilestream.obj \ $(OBJS)\test_filestream.obj \ @@ -262,6 +263,9 @@ $(OBJS)\test_stdstrings.obj: .\strings\stdstrings.cpp $(OBJS)\test_unicode.obj: .\strings\unicode.cpp $(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $** +$(OBJS)\test_crt.obj: .\strings\crt.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $** + $(OBJS)\test_bstream.obj: .\streams\bstream.cpp $(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $** diff --git a/tests/makefile.wat b/tests/makefile.wat index 9d58d9ef48..c86e9acc7c 100644 --- a/tests/makefile.wat +++ b/tests/makefile.wat @@ -103,6 +103,13 @@ __RUNTIME_LIBS_5 = -br !ifeq RUNTIME_LIBS static __RUNTIME_LIBS_5 = !endif +__EXCEPTIONSFLAG_6 = +!ifeq USE_EXCEPTIONS 0 +__EXCEPTIONSFLAG_6 = +!endif +!ifeq USE_EXCEPTIONS 1 +__EXCEPTIONSFLAG_6 = -xr +!endif __EXCEPTIONSFLAG_7 = !ifeq USE_EXCEPTIONS 0 __EXCEPTIONSFLAG_7 = @@ -169,7 +176,7 @@ SETUPHDIR = & TEST_CXXFLAGS = $(__DEBUGINFO_0) $(__OPTIMIZEFLAG_2) -bm $(__RUNTIME_LIBS_5) & -d__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__UNICODE_DEFINE_p) & -i=.\..\include -i=$(SETUPHDIR) -i=. $(__DLLFLAG_p) $(CPPUNIT_CFLAGS) & - $(__EXCEPTIONSFLAG_7) $(CPPFLAGS) $(CXXFLAGS) + $(__EXCEPTIONSFLAG_6) $(__EXCEPTIONSFLAG_7) $(CPPFLAGS) $(CXXFLAGS) TEST_OBJECTS = & $(OBJS)\test_test.obj & $(OBJS)\test_main.obj & @@ -183,6 +190,7 @@ TEST_OBJECTS = & $(OBJS)\test_strings.obj & $(OBJS)\test_stdstrings.obj & $(OBJS)\test_unicode.obj & + $(OBJS)\test_crt.obj & $(OBJS)\test_bstream.obj & $(OBJS)\test_ffilestream.obj & $(OBJS)\test_filestream.obj & @@ -256,6 +264,9 @@ $(OBJS)\test_stdstrings.obj : .AUTODEPEND .\strings\stdstrings.cpp $(OBJS)\test_unicode.obj : .AUTODEPEND .\strings\unicode.cpp $(CXX) -zq -fo=$^@ $(TEST_CXXFLAGS) $< +$(OBJS)\test_crt.obj : .AUTODEPEND .\strings\crt.cpp + $(CXX) -zq -fo=$^@ $(TEST_CXXFLAGS) $< + $(OBJS)\test_bstream.obj : .AUTODEPEND .\streams\bstream.cpp $(CXX) -zq -fo=$^@ $(TEST_CXXFLAGS) $< diff --git a/tests/strings/crt.cpp b/tests/strings/crt.cpp new file mode 100644 index 0000000000..a056270c18 --- /dev/null +++ b/tests/strings/crt.cpp @@ -0,0 +1,65 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/strings/crt.cpp +// Purpose: Test for wx C runtime functions wrappers +// Author: Vaclav Slavik +// Created: 2004-06-03 +// RCS-ID: $Id$ +// Copyright: (c) 2004 Vaclav Slavik +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/wx.h" +#endif // WX_PRECOMP + +#include "wx/textfile.h" + +#include "wx/cppunit.h" + +// ---------------------------------------------------------------------------- +// test class +// ---------------------------------------------------------------------------- + +class CrtTestCase : public CppUnit::TestCase +{ +public: + CrtTestCase() {} + +private: + CPPUNIT_TEST_SUITE( CrtTestCase ); + CPPUNIT_TEST( SetGetEnv ); + CPPUNIT_TEST_SUITE_END(); + + void SetGetEnv(); + + DECLARE_NO_COPY_CLASS(CrtTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( CrtTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( CrtTestCase, "CrtTestCase" ); + +void CrtTestCase::SetGetEnv() +{ + wxString val; + wxSetEnv(_T("TESTVAR"), _T("value")); + CPPUNIT_ASSERT( wxGetEnv(_T("TESTVAR"), &val) == true ); + CPPUNIT_ASSERT( val == _T("value") ); + wxSetEnv(_T("TESTVAR"), _T("something else")); + CPPUNIT_ASSERT( wxGetEnv(_T("TESTVAR"), &val) ); + CPPUNIT_ASSERT( val == _T("something else") ); + CPPUNIT_ASSERT( wxUnsetEnv(_T("TESTVAR")) ); + CPPUNIT_ASSERT( wxGetEnv(_T("TESTVAR"), NULL) == false ); +} diff --git a/tests/test.bkl b/tests/test.bkl index e7eb723ef7..0d0102281e 100644 --- a/tests/test.bkl +++ b/tests/test.bkl @@ -20,6 +20,7 @@ strings/strings.cpp strings/stdstrings.cpp strings/unicode.cpp + strings/crt.cpp streams/bstream.cpp streams/ffilestream.cpp streams/filestream.cpp diff --git a/tests/test.dsp b/tests/test.dsp index e983c5ba38..785d40170a 100644 --- a/tests/test.dsp +++ b/tests/test.dsp @@ -443,6 +443,10 @@ SOURCE=.\streams\bstream.cpp # End Source File # Begin Source File +SOURCE=.\strings\crt.cpp +# End Source File +# Begin Source File + SOURCE=.\streams\ffilestream.cpp # End Source File # Begin Source File -- 2.45.2