#include <wx/file.h>
#include <wx/app.h>
+// without this pragma, the stupid compiler precompiles #defines below so that
+// changing them doesn't "take place" later!
+#ifdef __VISUALC__
+ #pragma hdrstop
+#endif
+
// ----------------------------------------------------------------------------
// conditional compilation
// ----------------------------------------------------------------------------
-// what to test?
+// what to test (in alphabetic order)?
//#define TEST_ARRAYS
//#define TEST_CMDLINE
+//#define TEST_DATETIME
//#define TEST_DIR
-#define TEST_EXECUTE
+//#define TEST_EXECUTE
//#define TEST_FILECONF
//#define TEST_HASH
//#define TEST_LOG
//#define TEST_SOCKETS
//#define TEST_STRINGS
//#define TEST_THREADS
-//#define TEST_TIME
+#define TEST_TIMER
// ============================================================================
// implementation
// ============================================================================
-#ifdef TEST_CMDLINE
-
// ----------------------------------------------------------------------------
// wxCmdLineParser
// ----------------------------------------------------------------------------
+#ifdef TEST_CMDLINE
+
#include <wx/cmdline.h>
#include <wx/datetime.h>
#endif // TEST_SOCKETS
+// ----------------------------------------------------------------------------
+// timers
+// ----------------------------------------------------------------------------
+
+#ifdef TEST_TIMER
+
+#include <wx/timer.h>
+#include <wx/utils.h>
+
+static void TestStopWatch()
+{
+ puts("*** Testing wxStopWatch ***\n");
+
+ wxStopWatch sw;
+ printf("Sleeping 3 seconds...");
+ wxSleep(3);
+ printf("\telapsed time: %ldms\n", sw.Time());
+
+ sw.Pause();
+ printf("Sleeping 2 more seconds...");
+ wxSleep(2);
+ printf("\telapsed time: %ldms\n", sw.Time());
+
+ sw.Resume();
+ printf("And 3 more seconds...");
+ wxSleep(3);
+ printf("\telapsed time: %ldms\n", sw.Time());
+
+ wxStopWatch sw2;
+ puts("\nChecking for 'backwards clock' bug...");
+ for ( size_t n = 0; n < 70; n++ )
+ {
+ sw2.Start();
+
+ for ( size_t m = 0; m < 100000; m++ )
+ {
+ if ( sw.Time() < 0 || sw2.Time() < 0 )
+ {
+ puts("\ntime is negative - ERROR!");
+ }
+ }
+
+ putchar('.');
+ }
+
+ puts(", ok.");
+}
+
+#endif // TEST_TIMER
+
// ----------------------------------------------------------------------------
// date time
// ----------------------------------------------------------------------------
-#ifdef TEST_TIME
+#ifdef TEST_DATETIME
#include <wx/date.h>
#endif // 0
-#endif // TEST_TIME
+#endif // TEST_DATETIME
// ----------------------------------------------------------------------------
// threads
TestSocketClient();
#endif // TEST_SOCKETS
-#ifdef TEST_TIME
+#ifdef TEST_TIMER
+ TestStopWatch();
+#endif // TEST_TIMER
+
+#ifdef TEST_DATETIME
if ( 0 )
{
TestTimeSet();
TestTimeHolidays();
if ( 0 )
TestInteractive();
-#endif // TEST_TIME
+#endif // TEST_DATETIME
wxUninitialize();