summaryrefslogtreecommitdiff
path: root/src/test/test-calendarspec.c
diff options
context:
space:
mode:
authorDouglas Christman <DouglasChristman@gmail.com>2016-12-15 20:02:10 -0500
committerDouglas Christman <DouglasChristman@gmail.com>2016-12-16 19:27:33 -0500
commita2eb5ea79c53620cfcf616e83bfac0c431247f86 (patch)
tree0240d5031e9a111999c765c04d00395304d32e48 /src/test/test-calendarspec.c
parentebc8968bc0b6fc460099041f5ae1262ca17eeb6e (diff)
calendarspec: allow repetition values with ranges
"Every other hour from 9 until 5" can be written as `9..17/2:00` instead of `9,11,13,15,17:00`
Diffstat (limited to 'src/test/test-calendarspec.c')
-rw-r--r--src/test/test-calendarspec.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/test/test-calendarspec.c b/src/test/test-calendarspec.c
index b8320b081b..5fd749a6a8 100644
--- a/src/test/test-calendarspec.c
+++ b/src/test/test-calendarspec.c
@@ -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,10 @@ 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_next("2016-03-27 03:17:00", "", 12345, 1459048620000000);
test_next("2016-03-27 03:17:00", "CET", 12345, 1459041420000000);
@@ -207,6 +210,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 +231,13 @@ 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);
test_timestamp();
test_hourly_bug_4031();