Skip to content

Commit

Permalink
icalrecur_test: Restructure test cases and remove redundant tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
minichma committed Oct 22, 2024
1 parent 2972138 commit 3f0d4c6
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 420 deletions.
52 changes: 33 additions & 19 deletions src/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ testme(builtin_timezones "${builtin_timezones_SRCS}")
########### next target ###############
if(NOT CYGWIN AND NOT USE_32BIT_TIME_T)
set(icalrecurtest_SRCS icalrecur_test.c)
configure_file(icalrecur_test.out icalrecur_test.out COPYONLY)
configure_file(icalrecur_withicu_test.out icalrecur_withicu_test.out COPYONLY)
configure_file(icalrecur_withouticu_test.out icalrecur_withouticu_test.out COPYONLY)
configure_file(icalrecur_withicu_dangi_test.out icalrecur_withicu_dangi_test.out COPYONLY)
configure_file(icalrecur_test.txt icalrecur_test.txt COPYONLY)
configure_file(icalrecur_test_rscale.txt icalrecur_test_rscale.txt COPYONLY)
configure_file(icalrecur_test_rscale_withicu.txt icalrecur_test_rscale_withicu.txt COPYONLY)
configure_file(icalrecur_test_rscale_withicu_dangi.txt icalrecur_test_rscale_withicu_dangi.txt COPYONLY)
add_executable(icalrecurtest ${icalrecurtest_SRCS})
target_link_libraries(icalrecurtest ical icalss icalvcal)
if(WITH_CXX_BINDINGS)
Expand All @@ -193,27 +193,41 @@ if(NOT CYGWIN AND NOT USE_32BIT_TIME_T)
endif()
set(test_cmd "${PROJECT_BINARY_DIR}/src/test/icalrecurtest${CMAKE_EXECUTABLE_SUFFIX}")

#test rscale capable rrules
if(HAVE_ICU_DANGI)
set(reference_data "icalrecur_withicu_dangi_test.out")
elseif(ICU_FOUND)
set(reference_data "icalrecur_withicu_test.out")
else()
set(reference_data "icalrecur_withouticu_test.out")
endif()
set(test_args "-f ${PROJECT_BINARY_DIR}/src/test/${reference_data}")
add_test(NAME icalrecurtest-r COMMAND ${CMAKE_COMMAND} -D test_cmd=${test_cmd} -D test_args:string=${test_args} -P
${PROJECT_SOURCE_DIR}/cmake/run_test.cmake
)
setprops(icalrecurtest-r)

#test non-rscale rrules
set(reference_data "icalrecur_test.out")
set(reference_data "icalrecur_test.txt")
set(test_args "-f ${PROJECT_BINARY_DIR}/src/test/${reference_data}")
add_test(NAME icalrecurtest COMMAND ${CMAKE_COMMAND} -D test_cmd=${test_cmd} -D test_args:string=${test_args} -P
${PROJECT_SOURCE_DIR}/cmake/run_test.cmake
)
setprops(icalrecurtest)

#test rscale rrules without ICU
set(reference_data "icalrecur_test_rscale.txt")
set(test_args "-f ${PROJECT_BINARY_DIR}/src/test/${reference_data}")
add_test(NAME icalrecurtest-rscale COMMAND ${CMAKE_COMMAND} -D test_cmd=${test_cmd} -D test_args:string=${test_args} -P
${PROJECT_SOURCE_DIR}/cmake/run_test.cmake
)
setprops(icalrecurtest-rscale)

if(ICU_FOUND)
#test rscale rrules with ICU
set(reference_data "icalrecur_test_rscale_withicu.txt")
set(test_args "-f ${PROJECT_BINARY_DIR}/src/test/${reference_data}")
add_test(NAME icalrecurtest-rscale-withicu COMMAND ${CMAKE_COMMAND} -D test_cmd=${test_cmd} -D test_args:string=${test_args} -P
${PROJECT_SOURCE_DIR}/cmake/run_test.cmake
)
setprops(icalrecurtest-rscale-withicu)

if(HAVE_ICU_DANGI)
#test rscale rrules with ICU and DANGI
set(reference_data "icalrecur_test_rscale_withicu_dangi.txt")
set(test_args "-f ${PROJECT_BINARY_DIR}/src/test/${reference_data}")
add_test(NAME icalrecurtest-rscale-withicu-dangi COMMAND ${CMAKE_COMMAND} -D test_cmd=${test_cmd} -D test_args:string=${test_args} -P
${PROJECT_SOURCE_DIR}/cmake/run_test.cmake
)
setprops(icalrecurtest-rscale-withicu-dangi)
endif()
endif()
endif()

########### next target ###############
Expand Down
2 changes: 1 addition & 1 deletion src/test/icalrecur_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ int check_and_copy_field(const char *line, const char *pref, char *field, size_t
int main(int argc, char *argv[])
{
/* Default to RFC 5545 tests */
const char *file_name = "icalrecur_test.out";
const char *file_name = "icalrecur_test.txt";
int verbose = 0;

/* Do not use getopt for command line parsing -- for portability on Windows */
Expand Down
File renamed without changes.
File renamed without changes.
114 changes: 114 additions & 0 deletions src/test/icalrecur_test_rscale_withicu.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@

# Ethiopic last day of year
RRULE:RSCALE=ETHIOPIC;FREQ=YEARLY;BYMONTH=13;BYMONTHDAY=-1;COUNT=6
DTSTART:20140910
INSTANCES:20140910,20150911,20160910,20170910,20180910,20190911
PREV-INSTANCES:20180910,20170910,20160910,20150911,20140910

# Chinese New Year
RRULE:RSCALE=CHINESE;FREQ=YEARLY;UNTIL=20180101
DTSTART:20130210
INSTANCES:20130210,20140131,20150219,20160208,20170128
PREV-INSTANCES:20170128,20160208,20150219,20140131,20130210

# Chinese monthly
RRULE:RSCALE=CHINESE;FREQ=MONTHLY;COUNT=4
DTSTART:20140920
INSTANCES:20140920,20141020,20141119,20141218
PREV-INSTANCES:20141119,20141020,20140920

# Islamic monthly
RRULE:RSCALE=ISLAMIC-CIVIL;FREQ=MONTHLY;COUNT=4
DTSTART:20131025
INSTANCES:20131025,20131124,20131224,20140122
PREV-INSTANCES:20131224,20131124,20131025

# Islamic Ramadan
RRULE:RSCALE=ISLAMIC-CIVIL;FREQ=YEARLY;BYMONTH=9;COUNT=5
DTSTART:20130709
INSTANCES:20130709,20140629,20150618,20160607,20170527
PREV-INSTANCES:20160607,20150618,20140629,20130709

# Chinese leap month (no leap)
RRULE:RSCALE=CHINESE;FREQ=YEARLY;BYMONTHDAY=10;BYMONTH=9;COUNT=3
DTSTART:20131025
INSTANCES:20141003,20151022,20161010
PREV-INSTANCES:20151022,20141003

# Chinese leap month (omit)
RRULE:RSCALE=CHINESE;FREQ=YEARLY;BYMONTHDAY=10;BYMONTH=9L;SKIP=OMIT;COUNT=2
DTSTART:20131025
INSTANCES:20141102,21091102
PREV-INSTANCES:20141102

RRULE:RSCALE=CHINESE;FREQ=YEARLY;BYMONTHDAY=10;BYMONTH=4L;SKIP=OMIT;UNTIL=21000101
DTSTART:20131025
INSTANCES:20200601,20580531,20690530,20770531,20880530,20960531
PREV-INSTANCES:20960531,20880530,20770531,20690530,20580531,20200601

# Chinese leap month (skip forward)
RRULE:RSCALE=CHINESE;FREQ=YEARLY;BYMONTHDAY=10;BYMONTH=9L;SKIP=FORWARD;COUNT=3
DTSTART:20131025
INSTANCES:20131112,20141102,20151121
PREV-INSTANCES:20141102,20131112

# Chinese leap month (skip back)
RRULE:RSCALE=CHINESE;FREQ=YEARLY;BYMONTHDAY=10;BYMONTH=9L;SKIP=BACKWARD;COUNT=3
DTSTART:20131025
INSTANCES:20141102,20151022,20161010
PREV-INSTANCES:20151022,20141102

# Chinese leap month (both)
RRULE:RSCALE=CHINESE;FREQ=YEARLY;BYMONTHDAY=10;BYMONTH=9,9L;SKIP=BACKWARD;COUNT=4
DTSTART:20131025
INSTANCES:20141003,20141102,20151022,20161010
PREV-INSTANCES:20151022,20141102,20141003

# Every other Chinese New Year, starting at Jan 1, 2016
RRULE:RSCALE=CHINESE;FREQ=YEARLY;UNTIL=20200101;INTERVAL=2
DTSTART:20130210
START-AT:20160101
INSTANCES:20170128,20190205
PREV-INSTANCES:20150219,20130210

# Jewish leap month (omit)
RRULE:RSCALE=HEBREW;FREQ=YEARLY;COUNT=4
DTSTART:20140205
INSTANCES:20140205,20160214,20190210,20220206
PREV-INSTANCES:20190210,20160214,20140205

# Jewish leap month (skip forward)
RRULE:RSCALE=HEBREW;FREQ=YEARLY;SKIP=FORWARD;COUNT=4
DTSTART:20140205
INSTANCES:20140205,20150224,20160214,20170303
PREV-INSTANCES:20160214,20150224,20140205

# Jewish leap month (skip forward by month)
RRULE:RSCALE=HEBREW;FREQ=YEARLY;BYMONTH=5L;BYMONTHDAY=8;SKIP=FORWARD;COUNT=5
DTSTART:20140208
INSTANCES:20140208,20150227,20160217,20170306,20180223
PREV-INSTANCES:20170306,20160217,20150227,20140208

# 30th day of Jewish leap month (skip forward)
RRULE:RSCALE=HEBREW;FREQ=YEARLY;BYMONTH=5L;BYMONTHDAY=30;SKIP=FORWARD;COUNT=5
DTSTART:20140302
INSTANCES:20140302,20150321,20160310,20170328,20180317
PREV-INSTANCES:20170328,20160310,20150321,20140302

# Last day of Jewish leap month (skip forward)
RRULE:RSCALE=HEBREW;FREQ=YEARLY;BYMONTH=5L;BYMONTHDAY=-1;SKIP=FORWARD;COUNT=5
DTSTART:20140302
INSTANCES:20140302,20150320,20160310,20170327,20180316
PREV-INSTANCES:20170327,20160310,20150320,20140302

# 30th day of Jewish leap month (skip backward)
RRULE:RSCALE=HEBREW;FREQ=YEARLY;BYMONTH=5L;BYMONTHDAY=30;SKIP=BACKWARD;COUNT=5
DTSTART:20140302
INSTANCES:20140302,20150219,20160310,20170226,20180215
PREV-INSTANCES:20170226,20160310,20150219,20140302

# Last day of Jewish leap month (skip backward)
RRULE:RSCALE=HEBREW;FREQ=YEARLY;BYMONTH=5L;BYMONTHDAY=-1;SKIP=BACKWARD;COUNT=5
DTSTART:20140302
INSTANCES:20140302,20150219,20160310,20170226,20180215
PREV-INSTANCES:20170226,20160310,20150219,20140302
6 changes: 6 additions & 0 deletions src/test/icalrecur_test_rscale_withicu_dangi.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

# Korean Buddha birthday
RRULE:RSCALE=DANGI;FREQ=YEARLY;BYMONTHDAY=8;BYMONTH=4;UNTIL=20160101
DTSTART:20131025
INSTANCES:20140506,20150525
PREV-INSTANCES:20150525,20140506
Loading

0 comments on commit 3f0d4c6

Please sign in to comment.