ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
1ff636
From 33d01e64bc4e286e4eb772de8b3781686c2d3a3a Mon Sep 17 00:00:00 2001
1ff636
From: Daniel Mack <daniel@zonque.org>
1ff636
Date: Tue, 24 Feb 2015 13:27:10 +0100
1ff636
Subject: [PATCH] test-time: test "infinity" parsing in nanoseconds
1ff636
1ff636
(cherry picked from commit fdd30a1530810b659345c565e97beef06b7af2fd)
1ff636
---
1ff636
 src/test/test-time.c | 6 ++++++
1ff636
 1 file changed, 6 insertions(+)
1ff636
1ff636
diff --git a/src/test/test-time.c b/src/test/test-time.c
181b3f
index 8cfc4cc4f..3840fff06 100644
1ff636
--- a/src/test/test-time.c
1ff636
+++ b/src/test/test-time.c
1ff636
@@ -78,12 +78,18 @@ static void test_parse_nsec(void) {
1ff636
         assert_se(u == 2);
1ff636
         assert_se(parse_nsec(".7", &u) >= 0);
1ff636
         assert_se(u == 0);
1ff636
+        assert_se(parse_nsec("infinity", &u) >= 0);
1ff636
+        assert_se(u == NSEC_INFINITY);
1ff636
+        assert_se(parse_nsec(" infinity ", &u) >= 0);
1ff636
+        assert_se(u == NSEC_INFINITY);
1ff636
 
1ff636
         assert_se(parse_nsec(" xyz ", &u) < 0);
1ff636
         assert_se(parse_nsec("", &u) < 0);
1ff636
         assert_se(parse_nsec(" . ", &u) < 0);
1ff636
         assert_se(parse_nsec(" 5. ", &u) < 0);
1ff636
         assert_se(parse_nsec(".s ", &u) < 0);
1ff636
+        assert_se(parse_nsec(" infinity .7", &u) < 0);
1ff636
+        assert_se(parse_nsec(".3 infinity", &u) < 0);
1ff636
 }
1ff636
 
1ff636
 static void test_format_timespan_one(usec_t x, usec_t accuracy) {