summaryrefslogtreecommitdiff
path: root/src/test/test-time.c
diff options
context:
space:
mode:
authorDaniel Mack <github@zonque.org>2016-02-10 13:39:48 +0100
committerDaniel Mack <github@zonque.org>2016-02-10 13:39:48 +0100
commit978d6650863f02942a4a180cacfc9d28f310d930 (patch)
treea10da7e0d190edb8d8671907c6c13fa8a7f3c7c9 /src/test/test-time.c
parent42caedb2aae782659413f0f50ab824d58065c190 (diff)
parent04a1d84cefe4dbb5bfee86190489c3c07a8c238c (diff)
Merge pull request #2564 from poettering/fix-2467
Fix for #2467
Diffstat (limited to 'src/test/test-time.c')
-rw-r--r--src/test/test-time.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/test/test-time.c b/src/test/test-time.c
index 254a8d0e52..fdbf9fa881 100644
--- a/src/test/test-time.c
+++ b/src/test/test-time.c
@@ -191,6 +191,18 @@ static void test_usec_add(void) {
assert_se(usec_add(USEC_INFINITY, 2) == USEC_INFINITY);
}
+static void test_usec_sub(void) {
+ assert_se(usec_sub(0, 0) == 0);
+ assert_se(usec_sub(4, 1) == 3);
+ assert_se(usec_sub(4, 4) == 0);
+ assert_se(usec_sub(4, 5) == 0);
+ assert_se(usec_sub(USEC_INFINITY-3, -3) == USEC_INFINITY);
+ assert_se(usec_sub(USEC_INFINITY-3, -3) == USEC_INFINITY);
+ assert_se(usec_sub(USEC_INFINITY-3, -4) == USEC_INFINITY);
+ assert_se(usec_sub(USEC_INFINITY-3, -5) == USEC_INFINITY);
+ assert_se(usec_sub(USEC_INFINITY, 5) == USEC_INFINITY);
+}
+
int main(int argc, char *argv[]) {
uintmax_t x;
@@ -203,6 +215,7 @@ int main(int argc, char *argv[]) {
test_timezone_is_valid();
test_get_timezones();
test_usec_add();
+ test_usec_sub();
/* Ensure time_t is signed */
assert_cc((time_t) -1 < (time_t) 1);