//#define TEST_ARRAYS
//#define TEST_CMDLINE
-#define TEST_DATETIME
+//#define TEST_DATETIME
//#define TEST_DIR
//#define TEST_DLLLOADER
//#define TEST_EXECUTE
-//#define TEST_FILE
+#define TEST_FILE
//#define TEST_FILECONF
//#define TEST_HASH
//#define TEST_LIST
//#define TEST_STRINGS
//#define TEST_THREADS
//#define TEST_TIMER
-//#define TEST_VCARD
+//#define TEST_VCARD -- don't enable this (VZ)
//#define TEST_WCHAR
//#define TEST_ZIP
+//#define TEST_ZLIB
// ----------------------------------------------------------------------------
// test class for container objects
puts("File dump:\n----------");
- static const size_t len = 1024;
+ static const off_t len = 1024;
char buf[len];
for ( ;; )
{
{
printf("Number of lines: %u\n", file.GetLineCount());
printf("Last line: '%s'\n", file.GetLastLine().c_str());
+
+ wxString s;
+
+ puts("\nDumping the entire file:");
+ for ( s = file.GetFirstLine(); !file.Eof(); s = file.GetNextLine() )
+ {
+ printf("%6u: %s\n", file.GetCurrentLine() + 1, s.c_str());
+ }
+ printf("%6u: %s\n", file.GetCurrentLine() + 1, s.c_str());
+
+ puts("\nAnd now backwards:");
+ for ( s = file.GetLastLine();
+ file.GetCurrentLine() != 0;
+ s = file.GetPrevLine() )
+ {
+ printf("%6u: %s\n", file.GetCurrentLine() + 1, s.c_str());
+ }
+ printf("%6u: %s\n", file.GetCurrentLine() + 1, s.c_str());
}
else
{
#endif // TEST_ZIP
+// ----------------------------------------------------------------------------
+// ZLIB stream
+// ----------------------------------------------------------------------------
+
+#ifdef TEST_ZLIB
+
+#include <wx/zstream.h>
+#include <wx/wfstream.h>
+
+static const wxChar *FILENAME_GZ = _T("test.gz");
+static const char *TEST_DATA = "hello and hello again";
+
+static void TestZlibStreamWrite()
+{
+ puts("*** Testing Zlib stream reading ***\n");
+
+ wxFileOutputStream fileOutStream(FILENAME_GZ);
+ wxZlibOutputStream ostr(fileOutStream, 0);
+ printf("Compressing the test string... ");
+ ostr.Write(TEST_DATA, sizeof(TEST_DATA));
+ if ( !ostr )
+ {
+ puts("(ERROR: failed)");
+ }
+ else
+ {
+ puts("(ok)");
+ }
+
+ puts("\n----- done ------");
+}
+
+static void TestZlibStreamRead()
+{
+ puts("*** Testing Zlib stream reading ***\n");
+
+ wxFileInputStream fileInStream(FILENAME_GZ);
+ wxZlibInputStream istr(fileInStream);
+ printf("Archive size: %u\n", istr.GetSize());
+
+ puts("Dumping the file:");
+ while ( !istr.Eof() )
+ {
+ putchar(istr.GetC());
+ fflush(stdout);
+ }
+
+ puts("\n----- done ------");
+}
+
+#endif // TEST_ZLIB
+
// ----------------------------------------------------------------------------
// date time
// ----------------------------------------------------------------------------
printf("Now = %s\n", dt1.Format("%H:%M:%S:%l").c_str());
printf("UNow = %s\n", dt2.Format("%H:%M:%S:%l").c_str());
- printf("Difference is %s\n", (dt2 - dt1).Format("%l").c_str());
+ printf("Dummy loop: ");
+ for ( int i = 0; i < 6000; i++ )
+ {
+ //for ( int j = 0; j < 10; j++ )
+ {
+ wxString s;
+ s.Printf("%g", sqrt(i));
+ }
+
+ if ( !(i % 100) )
+ putchar('.');
+ }
+ puts(", done");
+
+ dt1 = dt2;
+ dt2 = wxDateTime::UNow();
+ printf("UNow = %s\n", dt2.Format("%H:%M:%S:%l").c_str());
+
+ printf("Loop executed in %s ms\n", (dt2 - dt1).Format("%l").c_str());
puts("\n*** done ***");
}
#endif // TEST_LOG
#ifdef TEST_FILE
- TestFileRead();
+ if ( 0 )
+ TestFileRead();
TestTextFileRead();
#endif // TEST_FILE
TestTimeArithmetics();
TestTimeHolidays();
TestTimeFormat();
+ TestTimeMS();
TestTimeZoneBug();
}
- TestTimeMS();
if ( 0 )
TestInteractive();
#endif // TEST_DATETIME
TestZipStreamRead();
#endif // TEST_ZIP
+#ifdef TEST_ZLIB
+ if ( 0 )
+ TestZlibStreamWrite();
+ TestZlibStreamRead();
+#endif // TEST_ZLIB
+
wxUninitialize();
return 0;