aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/time.c20
-rw-r--r--test/time_test_private.h1
2 files changed, 21 insertions, 0 deletions
diff --git a/test/time.c b/test/time.c
index 4307fd1..017597b 100644
--- a/test/time.c
+++ b/test/time.c
@@ -27,6 +27,7 @@ int time_test(char *testname)
{"add", rin_time_add_test},
{"sub", rin_time_sub_test},
{"normalize", rin_time_normalize_test},
+ {"cmp", rin_time_cmp_test},
{"cmpless", rin_time_cmpless_test},
{"cmpmore", rin_time_cmpmore_test},
{"cmplessequal", rin_time_cmplessequal_test},
@@ -111,6 +112,25 @@ static int rin_time_normalize_test(void)
return ret;
}
+static int rin_time_cmp_test(void)
+{
+ int ret;
+ size_t i;
+ static const struct timespec in_a[] = { {187, 100}, {1, 100}, {1, 200}, {1, 100}, {9, 10}, {3, 100}, {4, 101}, {0, 0} };
+ static const struct timespec in_b[] = { {187, 100}, {0, 100}, {1, 200}, {1, 200}, {10, 10}, {4, 101}, {3, 100}, {0, 0} };
+ static const long int expected[] = {0, 1, 0, -100, -1, -1, 1, 0};
+
+ for (i = 0; i < arrlen(expected); ++i) {
+ ret = ok(rin_time_cmp(in_a + i, in_b + i) != expected[i],
+ "%s: expected: %li, got: %li",
+ __func__,
+ expected[i],
+ rin_time_cmp(in_a + i, in_b + i));
+ }
+
+ return ret;
+}
+
static int rin_time_cmpless_test(void)
{
int ret;
diff --git a/test/time_test_private.h b/test/time_test_private.h
index 9afbda2..c7d505c 100644
--- a/test/time_test_private.h
+++ b/test/time_test_private.h
@@ -26,6 +26,7 @@
static int rin_time_add_test(void);
static int rin_time_sub_test(void);
static int rin_time_normalize_test(void);
+static int rin_time_cmp_test(void);
static int rin_time_cmpless_test(void);
static int rin_time_cmpmore_test(void);
static int rin_time_cmplessequal_test(void);