summaryrefslogtreecommitdiffhomepage
path: root/src/test/nxt_msec_diff_test.c
diff options
context:
space:
mode:
authorAndrey Zelenkov <zelenkov@nginx.com>2017-11-21 18:55:28 +0300
committerAndrey Zelenkov <zelenkov@nginx.com>2017-11-21 18:55:28 +0300
commit78a77c3e38593a5dd1ba0970d036ed5f5100f88d (patch)
tree3011f02b551c623a926e85ed1532986b947da300 /src/test/nxt_msec_diff_test.c
parent89a1c66dd0c396cda30a960e790817d28dc9a2de (diff)
downloadunit-78a77c3e38593a5dd1ba0970d036ed5f5100f88d.tar.gz
unit-78a77c3e38593a5dd1ba0970d036ed5f5100f88d.tar.bz2
Tests: move existing tests to "src" folder.
Diffstat (limited to 'src/test/nxt_msec_diff_test.c')
-rw-r--r--src/test/nxt_msec_diff_test.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/test/nxt_msec_diff_test.c b/src/test/nxt_msec_diff_test.c
new file mode 100644
index 00000000..5af7c011
--- /dev/null
+++ b/src/test/nxt_msec_diff_test.c
@@ -0,0 +1,46 @@
+
+/*
+ * Copyright (C) Igor Sysoev
+ * Copyright (C) NGINX, Inc.
+ */
+
+#include <nxt_main.h>
+#include "nxt_tests.h"
+
+
+static const nxt_msec_t pairs[] = {
+
+ 0x00000000, 0x00000001,
+ 0x00000000, 0x7fffffff,
+
+ 0x7fffffff, 0x80000000,
+ 0x7fffffff, 0x80000001,
+
+ 0x80000000, 0x80000001,
+ 0x80000000, 0xffffffff,
+
+ 0xffffffff, 0x00000000,
+ 0xffffffff, 0x00000001,
+};
+
+
+nxt_int_t
+nxt_msec_diff_test(nxt_thread_t *thr, nxt_msec_less_t less)
+{
+ nxt_uint_t i;
+
+ nxt_thread_time_update(thr);
+
+ for (i = 0; i < nxt_nitems(pairs); i += 2) {
+
+ if (!less(pairs[i], pairs[i + 1])) {
+ nxt_log_alert(thr->log,
+ "msec diff test failed: 0x%08XM 0x%08XM",
+ pairs[i], pairs[i + 1]);
+ return NXT_ERROR;
+ }
+ }
+
+ nxt_log_error(NXT_LOG_NOTICE, thr->log, "msec diff test passed");
+ return NXT_OK;
+}