From f01bb90321eacdf4a2a9f73ced6593f946db5349 Mon Sep 17 00:00:00 2001 From: Florian Knigge Date: Tue, 22 Oct 2024 12:51:44 +0200 Subject: [PATCH] More tests regarding usage of 'W' with multiple entries in DOM field --- ccronexpr_test.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ccronexpr_test.c b/ccronexpr_test.c index 71b8819..54b9f1e 100644 --- a/ccronexpr_test.c +++ b/ccronexpr_test.c @@ -377,6 +377,19 @@ void test_expr() { assert(check_next("0 0 1 1,3W * ?", "2022-09-02_00:00:00", "2022-09-02_01:00:00")); assert(check_next("0 0 1 1,3W * ?", "2022-09-03_00:00:00", "2022-10-01_01:00:00")); assert(check_next("0 0 1 1,3W * ?", "2022-10-02_00:00:00", "2022-10-03_01:00:00")); + // Check behaviour with more days mixed with W fields + assert(check_next("0 0 1 1,3W,15 * ?", "2022-09-01_00:00:00", "2022-09-01_01:00:00")); + assert(check_next("0 0 1 1,3W,15 * ?", "2022-09-02_00:00:00", "2022-09-02_01:00:00")); + assert(check_next("0 0 1 1,3W,15 * ?", "2022-09-03_00:00:00", "2022-09-15_01:00:00")); + assert(check_next("0 0 1 1,3W,15 * ?", "2022-09-16_00:00:00", "2022-10-01_01:00:00")); + assert(check_next("0 0 1 1,3W,15 * ?", "2022-10-02_00:00:00", "2022-10-03_01:00:00")); + assert(check_next("0 0 1 1,3W,15,16W * ?", "2022-09-01_00:00:00", "2022-09-01_01:00:00")); + assert(check_next("0 0 1 1,3W,15,16W * ?", "2022-09-02_00:00:00", "2022-09-02_01:00:00")); + assert(check_next("0 0 1 1,3W,15,16W * ?", "2022-09-03_00:00:00", "2022-09-15_01:00:00")); + assert(check_next("0 0 1 1,3W,15,16W * ?", "2022-09-16_00:00:00", "2022-09-16_01:00:00")); + assert(check_next("0 0 1 1,3W,15,16W * ?", "2022-09-17_00:00:00", "2022-10-01_01:00:00")); + assert(check_next("0 0 1 1,3W,15,16W * ?", "2022-10-02_00:00:00", "2022-10-03_01:00:00")); + assert(check_next("0 0 1 1,3W,15,16W * ?", "2025-02-16_00:00:00", "2025-02-17_01:00:00")); assert(check_next("0 0 1 1W,4W * ?", "2022-09-01_00:00:00", "2022-09-01_01:00:00")); assert(check_next("0 0 1 1W,4W * ?", "2022-09-02_00:00:00", "2022-09-05_01:00:00")); assert(check_next("0 0 1 1W,4W * ?", "2022-06-03_00:00:00", "2022-06-03_01:00:00")); @@ -488,6 +501,9 @@ void test_parse() { assert(check_same("* * * * 1 *", "* * * * 1 *")); assert(check_same("* * * * 1 L", "* * * * 1 SUN")); assert(check_same("* * * * * *", "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19-59,H 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18-59,H 0,1,2,3,4,5,6,7,8,9,10,11-23,H 1,2,3,4,5,6,7,8,9,10,11,12,13,14-31,H jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec,H mon,tue,wed,thu,fri,sat,sun,H")); + //assert(check_same("0 0 15 1,16,L * *", "0 0 15 1,L,16 * *")); + //assert(check_expr_valid("0 0 15 1,16,L * *")); + //assert(check_expr_valid("0 0 15 1,L,16 * *")); // check default hash func has valid output cron_init_custom_hash_fn(NULL); assert(check_expr_valid("0 0 1 * * ?"));