summaryrefslogtreecommitdiffstats
path: root/src/test/test-time-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/test-time-util.c')
-rw-r--r--src/test/test-time-util.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/test-time-util.c b/src/test/test-time-util.c
index eb6041c152..633544ff2e 100644
--- a/src/test/test-time-util.c
+++ b/src/test/test-time-util.c
@@ -85,6 +85,26 @@ static void test_parse_sec_fix_0(void) {
assert_se(u == USEC_INFINITY);
}
+static void test_parse_sec_def_infinity(void) {
+ usec_t u;
+
+ log_info("/* %s */", __func__);
+
+ assert_se(parse_sec_def_infinity("5s", &u) >= 0);
+ assert_se(u == 5 * USEC_PER_SEC);
+ assert_se(parse_sec_def_infinity("", &u) >= 0);
+ assert_se(u == USEC_INFINITY);
+ assert_se(parse_sec_def_infinity(" ", &u) >= 0);
+ assert_se(u == USEC_INFINITY);
+ assert_se(parse_sec_def_infinity("0s", &u) >= 0);
+ assert_se(u == 0);
+ assert_se(parse_sec_def_infinity("0", &u) >= 0);
+ assert_se(u == 0);
+ assert_se(parse_sec_def_infinity(" 0", &u) >= 0);
+ assert_se(u == 0);
+ assert_se(parse_sec_def_infinity("-5s", &u) < 0);
+}
+
static void test_parse_time(void) {
usec_t u;
@@ -472,6 +492,7 @@ int main(int argc, char *argv[]) {
test_parse_sec();
test_parse_sec_fix_0();
+ test_parse_sec_def_infinity();
test_parse_time();
test_parse_nsec();
test_format_timespan(1);