aboutsummaryrefslogtreecommitdiff
path: root/test/src
diff options
context:
space:
mode:
Diffstat (limited to 'test/src')
-rw-r--r--test/src/TestTimer.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/src/TestTimer.c b/test/src/TestTimer.c
new file mode 100644
index 0000000..b08dba8
--- /dev/null
+++ b/test/src/TestTimer.c
@@ -0,0 +1,36 @@
+#include <BH/Unit.h>
+#include <BH/Timer.h>
+#include <BH/Thread.h>
+
+
+BH_UNIT_TEST(General)
+{
+ BH_Timer *timer;
+
+ BH_VERIFY((timer = BH_TimerNew()) != NULL);
+ BH_ThreadSleep(5000);
+
+ BH_VERIFY(BH_TimerMilliseconds(timer) >= 5000);
+ BH_VERIFY(BH_TimerNanoseconds(timer) >= 5000000000);
+ BH_VERIFY(BH_TimerRestart(timer) >= 5000);
+ BH_VERIFY(BH_TimerRestart(timer) < 5000);
+
+ BH_ThreadSleep(5000);
+ BH_VERIFY(BH_TimerMilliseconds(timer) >= 5000);
+ BH_TimerStart(timer);
+ BH_VERIFY(BH_TimerMilliseconds(timer) < 5000);
+
+ BH_TimerFree(timer);
+ return 0;
+}
+
+
+int main(int argc, char **argv)
+{
+ (void)argc;
+ (void)argv;
+
+ BH_UNIT_ADD(General);
+
+ return BH_UnitRun();
+}