]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/test/test-calendarspec.c
calendarspec: fix duplicate detection (#5310)
[thirdparty/systemd.git] / src / test / test-calendarspec.c
index b8320b081bb445cbba189ed088b57fce92037641..f90b73aeaf31862e6540bd55c4daf6c65cb088d5 100644 (file)
@@ -149,8 +149,8 @@ int main(int argc, char* argv[]) {
         test_one("*-*-7 0:0:0", "*-*-07 00:00:00");
         test_one("10-15", "*-10-15 00:00:00");
         test_one("monday *-12-* 17:00", "Mon *-12-* 17:00:00");
-        test_one("Mon,Fri *-*-3,1,2 *:30:45", "Mon,Fri *-*-01..03 *:30:45");
-        test_one("12,14,13,12:20,10,30", "*-*-* 12..14:10,20,30:00");
+        test_one("Mon,Fri *-*-3,1,2 *:30:45", "Mon,Fri *-*-01,02,03 *:30:45");
+        test_one("12,14,13,12:20,10,30", "*-*-* 12,13,14:10,20,30:00");
         test_one("mon,fri *-1/2-1,3 *:30:45", "Mon,Fri *-01/2-01,03 *:30:45");
         test_one("03-05 08:05:40", "*-03-05 08:05:40");
         test_one("08:05:40", "*-*-* 08:05:40");
@@ -172,13 +172,12 @@ int main(int argc, char* argv[]) {
         test_one("2015-10-25 01:00:00 uTc", "2015-10-25 01:00:00 UTC");
         test_one("2016-03-27 03:17:00.4200005", "2016-03-27 03:17:00.420001");
         test_one("2016-03-27 03:17:00/0.42", "2016-03-27 03:17:00/0.420000");
-        test_one("2016-03-27 03:17:00/0.42", "2016-03-27 03:17:00/0.420000");
         test_one("9..11,13:00,30", "*-*-* 09..11,13:00,30:00");
         test_one("1..3-1..3 1..3:1..3", "*-01..03-01..03 01..03:01..03:00");
-        test_one("00:00:1.125..2.125", "*-*-* 00:00:01.125000,02.125000");
+        test_one("00:00:1.125..2.125", "*-*-* 00:00:01.125000..02.125000");
         test_one("00:00:1.0..3.8", "*-*-* 00:00:01..03");
         test_one("00:00:01..03", "*-*-* 00:00:01..03");
-        test_one("00:00:01/2,02..03", "*-*-* 00:00:01/2,02,03");
+        test_one("00:00:01/2,02..03", "*-*-* 00:00:01/2,02..03");
         test_one("*-*~1 Utc", "*-*~01 00:00:00 UTC");
         test_one("*-*~05,3 ", "*-*~03,05 00:00:00");
         test_one("*-*~* 00:00:00", "*-*-* 00:00:00");
@@ -189,6 +188,11 @@ int main(int argc, char* argv[]) {
         test_one("*:*", "*-*-* *:*:00");
         test_one("12:*", "*-*-* 12:*:00");
         test_one("*:30", "*-*-* *:30:00");
+        test_one("93..00-*-*", "1993..2000-*-* 00:00:00");
+        test_one("00..07-*-*", "2000..2007-*-* 00:00:00");
+        test_one("*:20..39/5", "*-*-* *:20..35/5:00");
+        test_one("00:00:20..40/1", "*-*-* 00:00:20..40");
+        test_one("*~03/1,03..05", "*-*~03/1,03..05 00:00:00");
 
         test_next("2016-03-27 03:17:00", "", 12345, 1459048620000000);
         test_next("2016-03-27 03:17:00", "CET", 12345, 1459041420000000);
@@ -207,6 +211,9 @@ int main(int argc, char* argv[]) {
         test_next("2016-02~01 UTC", "", 12345, 1456704000000000);
         test_next("Mon 2017-05~01..07 UTC", "", 12345, 1496016000000000);
         test_next("Mon 2017-05~07/1 UTC", "", 12345, 1496016000000000);
+        test_next("2017-08-06 9,11,13,15,17:00 UTC", "", 1502029800000000, 1502031600000000);
+        test_next("2017-08-06 9..17/2:00 UTC", "", 1502029800000000, 1502031600000000);
+        test_next("2016-12-* 3..21/6:00 UTC", "", 1482613200000001, 1482634800000000);
 
         assert_se(calendar_spec_from_string("test", &c) < 0);
         assert_se(calendar_spec_from_string(" utc", &c) < 0);
@@ -225,6 +232,15 @@ int main(int argc, char* argv[]) {
         assert_se(calendar_spec_from_string("-00:+00/-5", &c) < 0);
         assert_se(calendar_spec_from_string("00:+00/-5", &c) < 0);
         assert_se(calendar_spec_from_string("2016- 11- 24 12: 30: 00", &c) < 0);
+        assert_se(calendar_spec_from_string("*~29", &c) < 0);
+        assert_se(calendar_spec_from_string("*~16..31", &c) < 0);
+        assert_se(calendar_spec_from_string("12..1/2-*", &c) < 0);
+        assert_se(calendar_spec_from_string("*:05..05", &c) < 0);
+        assert_se(calendar_spec_from_string("*:05..10/6", &c) < 0);
+        assert_se(calendar_spec_from_string("20/4:00", &c) < 0);
+        assert_se(calendar_spec_from_string("00:00/60", &c) < 0);
+        assert_se(calendar_spec_from_string("00:00:2300", &c) < 0);
+        assert_se(calendar_spec_from_string("00:00:18446744073709551615", &c) < 0);
 
         test_timestamp();
         test_hourly_bug_4031();