]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/events/stopwatch.cpp
Added wxStopWatch::TimeInMicro() for better precision time measurement.
[wxWidgets.git] / tests / events / stopwatch.cpp
index 251a859c63170094950dcb451182635d1811b4e0..f50da74306beaf553ccbbaea4ee9732f8b6a5d04 100644 (file)
@@ -55,13 +55,22 @@ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( StopWatchTestCase, "StopWatchTestCase" );
 
 void StopWatchTestCase::Misc()
 {
 
 void StopWatchTestCase::Misc()
 {
-    static const long tolerance = 100;  // in ms
+    static const long tolerance = 10;  // in ms
 
     wxStopWatch sw;
     long t;
 
     wxStopWatch sw;
     long t;
+    wxLongLong usec;
 
     sw.Pause();         // pause it immediately
 
 
     sw.Pause();         // pause it immediately
 
+    // verify that almost no time elapsed
+    usec = sw.TimeInMicro();
+    WX_ASSERT_MESSAGE
+    (
+        ("Elapsed time was %" wxLongLongFmtSpec "dus", usec),
+        usec < tolerance*1000
+    );
+
     wxSleep(1);
     t = sw.Time();
 
     wxSleep(1);
     t = sw.Time();