mirror of
https://github.com/troglobit/libuev.git
synced 2026-11-08 16:10:59 +00:00
tests: Add basic error handling to callbacks, for reference
Many users look at both examples *and* unit tests to learn how to use a library. We should pride ourselves in that we have not just working but also correct and readable tests. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
9df7cbfc52
commit
505a7214a8
4 files changed
+29
-6
No files matched your search
+4
-1
@@ -5,10 +5,13 @@
|
||||
#define TIMEOUT 2 /* 2 sec */
|
||||
struct timeval start;
|
||||
|
||||
static void cb(uev_t *w, void *UNUSED(arg), int UNUSED(events))
|
||||
static void cb(uev_t *w, void *UNUSED(arg), int events)
|
||||
{
|
||||
struct timeval now;
|
||||
|
||||
if (UEV_ERROR == events)
|
||||
fprintf(stderr, "timer watcher failed, ignoring ...\n");
|
||||
|
||||
gettimeofday(&now, NULL);
|
||||
fail_unless(now.tv_sec == start.tv_sec + TIMEOUT);
|
||||
|
||||
|
||||
Reference in new issue
Block a user