From 13a0adb967c07ac84bbee8a614cd74425bf08da2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Sat, 10 Jun 2017 10:21:47 +0200 Subject: [PATCH] Add a minimal test for #8. --- tests/0-waitercount.d | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/0-waitercount.d diff --git a/tests/0-waitercount.d b/tests/0-waitercount.d new file mode 100644 index 0000000..578102a --- /dev/null +++ b/tests/0-waitercount.d @@ -0,0 +1,33 @@ +/++ dub.sdl: + name "test" + dependency "eventcore" path=".." ++/ +module test; + +import eventcore.core; +import core.stdc.signal; +import core.time : Duration, msecs; +import core.thread : Thread; + + +void test(Duration timeout) +{ + while (true) { + auto reason = eventDriver.core.processEvents(timeout); + final switch (reason) with (ExitReason) { + case exited: assert(false, "Manual exit without call to exit()!?"); + case timeout: assert(false, "Event loop timed out, although no waiters exist!?"); + case idle: break; + case outOfWaiters: return; + } + } +} + +void main() +{ + assert(eventDriver.core.waiterCount == 0, "Initial waiter count not 0!"); + test(100.msecs); + assert(eventDriver.core.waiterCount == 0, "Waiter count after outOfWaiters not 0!"); + test(Duration.max); + assert(eventDriver.core.waiterCount == 0); +}