diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test-time.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/test/test-time.c b/src/test/test-time.c index 69e12dd94c..9062c3f3c1 100644 --- a/src/test/test-time.c +++ b/src/test/test-time.c @@ -189,6 +189,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; @@ -201,6 +213,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); |