]> git.saurik.com Git - wxWidgets.git/commitdiff
added tests for wx's CRT wrappers (so far only wxGetEnv,wxSetEnv)
authorVáclav Slavík <vslavik@fastmail.fm>
Thu, 3 Jun 2004 19:48:31 +0000 (19:48 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Thu, 3 Jun 2004 19:48:31 +0000 (19:48 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27604 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

tests/Makefile.in
tests/makefile.bcc
tests/makefile.gcc
tests/makefile.vc
tests/makefile.wat
tests/strings/crt.cpp [new file with mode: 0644]
tests/test.bkl
tests/test.dsp

index 7ec05e078095f0eb05ebf8213f69f1022a2a0353..26df18762cdddadb96af022ae8b4b3190cf07cfc 100644 (file)
@@ -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) $<
 
index 56ddd10a19dc012fdceaa83b8fa323098dad665d..286725c4aaca2e50cd0d1df30b12a5d3fc97ad24 100644 (file)
@@ -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) $**
 
index c0335b58bf9e2aef1eabaf2e3b4f210f4d0bb876..bd6e8e83640443479f262f83e3717b5bbfccd507 100644 (file)
@@ -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) $<
 
index ba50e8d6069ceb57d0a5b3b63b49dea93e478949..17fb23c43889a9c2208e2eee994fb19fbee98963 100644 (file)
@@ -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) $**
 
index 9d58d9ef48b016931f646038546d2797cfa4d6ed..c86e9acc7c7fa46a5f88a513492376cfb0c734fd 100644 (file)
@@ -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 (file)
index 0000000..a056270
--- /dev/null
@@ -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 );
+}
index e7eb723ef7b71ca99daf96c166152b64a89d416a..0d0102281eec861280d37e8789b0d0765437c932 100644 (file)
@@ -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
index e983c5ba382fae6703ded35c96078570b0a03300..785d40170a908d477ee664b0f4bba61f9acbe333 100644 (file)
@@ -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