#define TEST_TEXTSTREAM
#define TEST_THREADS
#define TEST_TIMER
- #define TEST_UNICODE
// #define TEST_VCARD -- don't enable this (VZ)
// #define TEST_VOLUME --FIXME! (RN)
#define TEST_WCHAR
// wide char and Unicode support
// ----------------------------------------------------------------------------
-#ifdef TEST_UNICODE
-
-static void TestUnicodeToFromAscii()
-{
- wxPuts(_T("Testing wxString::To/FromAscii()\n"));
-
- static const char *msg = "Hello, world!";
- wxString s = wxString::FromAscii(msg);
-
- wxPrintf(_T("Message in Unicode: %s\n"), s.c_str());
- printf("Message in ASCII: %s\n", (const char *)s.ToAscii());
-
- wxPutchar(_T('\n'));
-}
-
-#include "wx/textfile.h"
-
-static void TestUnicodeTextFileRead()
-{
- wxPuts(_T("Testing wxTextFile in Unicode build\n"));
-
- wxTextFile file;
- if ( file.Open(_T("testdata.fc"), wxConvLocal) )
- {
- const size_t count = file.GetLineCount();
- for ( size_t n = 0; n < count; n++ )
- {
- const wxString& s = file[n];
-
- wxPrintf(_T("Line %u: \"%s\" (len %u, last char = '%c')\n"),
- (unsigned)n, s.c_str(), (unsigned)s.length(), s.Last());
- }
- }
-}
-
-#endif // TEST_UNICODE
-
#ifdef TEST_WCHAR
#include "wx/strconv.h"
TestFSVolume();
#endif // TEST_VOLUME
-#ifdef TEST_UNICODE
- TestUnicodeTextFileRead();
- #if TEST_ALL
- TestUnicodeToFromAscii();
- #endif
-#endif // TEST_UNICODE
-
#ifdef TEST_WCHAR
TestUtf8();
TestEncodingConverter();
test_arrays.o \
test_longlong.o \
test_strings.o \
+ test_unicode.o \
test_bstream.o \
test_ffilestream.o \
test_filestream.o \
### Targets: ###
-all: test$(EXEEXT)
+all: test$(EXEEXT) data
install: all
$(__test___mac_setfilecmd) $(SAMPLES_RPATH_POSTLINK)
+data:
+ @mkdir -p .
+ @for f in testdata.fc; do \
+ if test \( ! -s ./$$f \) -o \( $(srcdir)/$$f -nt ./$$f \) ; then \
+ cp -pRf $(srcdir)/$$f . ; \
+ fi; \
+ done
+
test_test.o: $(srcdir)/test.cpp
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $<
test_strings.o: $(srcdir)/strings/strings.cpp
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $<
+test_unicode.o: $(srcdir)/strings/unicode.cpp
+ $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $<
+
test_bstream.o: $(srcdir)/streams/bstream.cpp
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $<
# Include dependency info, if present:
@IF_GNU_MAKE@-include .deps/*.d
-.PHONY: all install uninstall clean distclean
+.PHONY: all install uninstall clean distclean data
$(OBJS)\test_arrays.obj \
$(OBJS)\test_longlong.obj \
$(OBJS)\test_strings.obj \
+ $(OBJS)\test_unicode.obj \
$(OBJS)\test_bstream.obj \
$(OBJS)\test_ffilestream.obj \
$(OBJS)\test_filestream.obj \
### Targets: ###
-all: $(OBJS)\test.exe
+all: $(OBJS)\test.exe data
clean:
-if exist $(OBJS)\*.obj del $(OBJS)\*.obj
c0x32.obj $(TEST_OBJECTS),$@,, $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) wxzlib$(WXDEBUGFLAG).lib wxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(__UNICOWS_LIB_p) ole2w32.lib oleacc.lib odbc32.lib import32.lib cw32mt$(__RUNTIME_LIBS_7).lib,,
|
+data:
+ if not exist $(OBJS) mkdir $(OBJS)
+ for %f in (testdata.fc) do if not exist $(OBJS)\%f copy .\%f $(OBJS)
+
$(OBJS)\test_test.obj: .\test.cpp
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $**
$(OBJS)\test_strings.obj: .\strings\strings.cpp
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $**
+$(OBJS)\test_unicode.obj: .\strings\unicode.cpp
+ $(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $**
+
$(OBJS)\test_bstream.obj: .\streams\bstream.cpp
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $**
$(OBJS)\test_arrays.o \
$(OBJS)\test_longlong.o \
$(OBJS)\test_strings.o \
+ $(OBJS)\test_unicode.o \
$(OBJS)\test_bstream.o \
$(OBJS)\test_ffilestream.o \
$(OBJS)\test_filestream.o \
### Targets: ###
-all: $(OBJS)\test.exe
+all: $(OBJS)\test.exe data
clean:
-if exist $(OBJS)\*.o del $(OBJS)\*.o
$(OBJS)\test.exe: $(TEST_OBJECTS)
$(CXX) -o $@ $(TEST_OBJECTS) $(LDFLAGS) $(__DEBUGINFO) -mthreads -L$(LIBDIRNAME) $(CPPUNIT_LIBS) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) -lwxzlib$(WXDEBUGFLAG) -lwxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG) -lwxexpat$(WXDEBUGFLAG) $(__UNICOWS_LIB_p) -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32 -lodbc32
+data:
+ if not exist $(OBJS) mkdir $(OBJS)
+ for %%f in (testdata.fc) do if not exist $(OBJS)\%%f copy .\%%f $(OBJS)
+
$(OBJS)\test_test.o: ./test.cpp
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $<
$(OBJS)\test_strings.o: ./strings/strings.cpp
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $<
+$(OBJS)\test_unicode.o: ./strings/unicode.cpp
+ $(CXX) -c -o $@ $(TEST_CXXFLAGS) $<
+
$(OBJS)\test_bstream.o: ./streams/bstream.cpp
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $<
$(OBJS)\test_zlibstream.o: ./streams/zlibstream.cpp
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $<
-.PHONY: all clean
+.PHONY: all clean data
$(OBJS)\test_arrays.obj \
$(OBJS)\test_longlong.obj \
$(OBJS)\test_strings.obj \
+ $(OBJS)\test_unicode.obj \
$(OBJS)\test_bstream.obj \
$(OBJS)\test_ffilestream.obj \
$(OBJS)\test_filestream.obj \
### Targets: ###
-all: $(OBJS)\test.exe
+all: $(OBJS)\test.exe data
clean:
-if exist $(OBJS)\*.obj del $(OBJS)\*.obj
$(TEST_OBJECTS) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) wxzlib$(WXDEBUGFLAG).lib wxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(__UNICOWS_LIB_p) kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib oleacc.lib odbc32.lib
<<
+data:
+ if not exist $(OBJS) mkdir $(OBJS)
+ for %f in (testdata.fc) do if not exist $(OBJS)\%f copy .\%f $(OBJS)
+
$(OBJS)\test_test.obj: .\test.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $**
$(OBJS)\test_strings.obj: .\strings\strings.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $**
+$(OBJS)\test_unicode.obj: .\strings\unicode.cpp
+ $(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $**
+
$(OBJS)\test_bstream.obj: .\streams\bstream.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $**
$(OBJS)\test_arrays.obj &
$(OBJS)\test_longlong.obj &
$(OBJS)\test_strings.obj &
+ $(OBJS)\test_unicode.obj &
$(OBJS)\test_bstream.obj &
$(OBJS)\test_ffilestream.obj &
$(OBJS)\test_filestream.obj &
### Targets: ###
-all : .SYMBOLIC $(OBJS)\test.exe
+all : .SYMBOLIC $(OBJS)\test.exe data
clean : .SYMBOLIC
-if exist $(OBJS)\*.obj del $(OBJS)\*.obj
@%append $(OBJS)\test.lbc
wlink @$(OBJS)\test.lbc
+data : .SYMBOLIC
+ if not exist $(OBJS) mkdir $(OBJS)
+ for %f in (testdata.fc) do if not exist $(OBJS)\%f copy .\%f $(OBJS)
+
$(OBJS)\test_test.obj : .AUTODEPEND .\test.cpp
$(CXX) -zq -fo=$^@ $(TEST_CXXFLAGS) $<
$(OBJS)\test_strings.obj : .AUTODEPEND .\strings\strings.cpp
$(CXX) -zq -fo=$^@ $(TEST_CXXFLAGS) $<
+$(OBJS)\test_unicode.obj : .AUTODEPEND .\strings\unicode.cpp
+ $(CXX) -zq -fo=$^@ $(TEST_CXXFLAGS) $<
+
$(OBJS)\test_bstream.obj : .AUTODEPEND .\streams\bstream.cpp
$(CXX) -zq -fo=$^@ $(TEST_CXXFLAGS) $<
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// Name: tests/strings/unicode.cpp
+// Purpose: Unicode unit test
+// Author: Vadim Zeitlin, Wlodzimierz ABX Skiba
+// Created: 2004-04-28
+// RCS-ID: $Id$
+// Copyright: (c) 2004 Vadim Zeitlin, Wlodzimierz Skiba
+///////////////////////////////////////////////////////////////////////////////
+
+// ----------------------------------------------------------------------------
+// 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 UnicodeTestCase : public CppUnit::TestCase
+{
+public:
+ UnicodeTestCase();
+
+private:
+ CPPUNIT_TEST_SUITE( UnicodeTestCase );
+ CPPUNIT_TEST( ToFromAscii );
+ CPPUNIT_TEST( TextFileRead );
+ CPPUNIT_TEST_SUITE_END();
+
+ void ToFromAscii();
+ void TextFileRead();
+
+ DECLARE_NO_COPY_CLASS(UnicodeTestCase)
+};
+
+// register in the unnamed registry so that these tests are run by default
+CPPUNIT_TEST_SUITE_REGISTRATION( UnicodeTestCase );
+
+// also include in it's own registry so that these tests can be run alone
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( UnicodeTestCase, "UnicodeTestCase" );
+
+UnicodeTestCase::UnicodeTestCase()
+{
+}
+
+void UnicodeTestCase::ToFromAscii()
+{
+
+#define TEST_TO_FROM_ASCII(txt) \
+ { \
+ static const char *msg = txt; \
+ wxString s = wxString::FromAscii(msg); \
+ CPPUNIT_ASSERT( strcmp( s.ToAscii() , msg ) == 0 ); \
+ }
+
+ TEST_TO_FROM_ASCII( "Hello, world!" );
+ TEST_TO_FROM_ASCII( "additional \" special \t test \\ component \n :-)" );
+}
+
+void UnicodeTestCase::TextFileRead()
+{
+ wxTextFile file;
+ bool file_opened = file.Open(_T("testdata.fc"), wxConvLocal);
+
+ CPPUNIT_ASSERT( file_opened );
+
+ static const wxChar *lines[6] = {
+ _T("# this is the test data file for wxFileConfig tests"),
+ _T("value1=one"),
+ _T("# a comment here"),
+ _T("value2=two"),
+ _T("value\\ with\\ spaces\\ inside\\ it=nothing special"),
+ _T("path=$PATH")
+ };
+
+ if( file_opened )
+ {
+ const size_t count = file.GetLineCount();
+ CPPUNIT_ASSERT( count == 6 );
+ for ( size_t n = 0; n < count; n++ )
+ {
+ CPPUNIT_ASSERT( wxStrcmp( file[n].c_str() , lines[n] ) == 0 );
+ }
+ }
+}
arrays/arrays.cpp
longlong/longlong.cpp
strings/strings.cpp
+ strings/unicode.cpp
streams/bstream.cpp
streams/ffilestream.cpp
streams/filestream.cpp
<wx-lib>base</wx-lib>
</exe>
+ <wx-data id="data">
+ <files>testdata.fc</files>
+ </wx-data>
+
</makefile>
# End Source File
# Begin Source File
+SOURCE=.\strings\unicode.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\regex\wxregex.cpp
# End Source File
# Begin Source File
--- /dev/null
+# this is the test data file for wxFileConfig tests
+value1=one
+# a comment here
+value2=two
+value\ with\ spaces\ inside\ it=nothing special
+path=$PATH