summaryrefslogtreecommitdiff
path: root/test/common
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2006-11-06 20:43:12 +0000
committerChris Wilson <chris+github@qwirx.com>2006-11-06 20:43:12 +0000
commit3a590d43ce5e108e42483993b3ce7bfaaa20d74d (patch)
tree56aeb826bce234eb3f2fe5e747fe8194a84d9c42 /test/common
parentee4dc408e4ce8364322ea19a4fabbb5e8edf4d46 (diff)
Added generic timer support class
Diffstat (limited to 'test/common')
-rw-r--r--test/common/testcommon.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/common/testcommon.cpp b/test/common/testcommon.cpp
index 4f82f587..48d6a67b 100644
--- a/test/common/testcommon.cpp
+++ b/test/common/testcommon.cpp
@@ -27,6 +27,7 @@
#include "autogen_ConversionException.h"
#include "CollectInBufferStream.h"
#include "Archive.h"
+#include "Timer.h"
#include "MemLeakFindOn.h"
@@ -204,6 +205,56 @@ int test(int argc, const char *argv[])
}
#endif // BOX_MEMORY_LEAK_TESTING
+ // Check that using timer methods without initialisation
+ // throws an exception
+ TEST_CHECK_THROWS(Timers::Add(*(Timer*)NULL),
+ CommonException, AssertFailed);
+ TEST_CHECK_THROWS(Timers::Remove(*(Timer*)NULL),
+ CommonException, AssertFailed);
+ TEST_CHECK_THROWS(Timers::Signal(), CommonException, AssertFailed);
+ TEST_CHECK_THROWS(Timers::Cleanup(), CommonException, AssertFailed);
+
+ // Check that we can initialise the timers
+ Timers::Init();
+
+ // Check that double initialisation throws an exception
+ TEST_CHECK_THROWS(Timers::Init(), CommonException, AssertFailed);
+
+ // Check that we can clean up the timers
+ Timers::Cleanup();
+
+ // Check that double cleanup throws an exception
+ TEST_CHECK_THROWS(Timers::Cleanup(), CommonException, AssertFailed);
+
+ Timers::Init();
+
+ Timer t1(1);
+ Timer t2(2);
+ Timer t3(3);
+
+ TEST_THAT(!t1.HasExpired());
+ TEST_THAT(!t2.HasExpired());
+ TEST_THAT(!t3.HasExpired());
+
+ sleep(1);
+ TEST_THAT(t1.HasExpired());
+ TEST_THAT(!t2.HasExpired());
+ TEST_THAT(!t3.HasExpired());
+
+ sleep(1);
+ TEST_THAT(t1.HasExpired());
+ TEST_THAT(t2.HasExpired());
+ TEST_THAT(!t3.HasExpired());
+
+ t1 = Timer(1);
+ t2 = Timer(2);
+ TEST_THAT(!t1.HasExpired());
+ TEST_THAT(!t2.HasExpired());
+
+ sleep(1);
+ TEST_THAT(t1.HasExpired());
+ TEST_THAT(!t2.HasExpired());
+ TEST_THAT(t3.HasExpired());
static char *testfilelines[] =
{