From 0c1e64a16e073a433f1e13b09fc88e4befd3f6f5 Mon Sep 17 00:00:00 2001 From: bjt-user Date: Sun, 3 Mar 2024 16:05:23 +0100 Subject: [PATCH 1/3] added test file --- tests/start_date_is_first_field.ics | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tests/start_date_is_first_field.ics diff --git a/tests/start_date_is_first_field.ics b/tests/start_date_is_first_field.ics new file mode 100644 index 0000000..4042033 --- /dev/null +++ b/tests/start_date_is_first_field.ics @@ -0,0 +1,12 @@ +BEGIN:VCALENDAR +BEGIN:VEVENT +DTSTART:20240413T070000Z +DTEND:20240413T083000Z +DTSTAMP:20240229T171200Z +SUMMARY:Kubernetes and Cloud Native Associate Exam (KCNA) +DESCRIPTION:Kubernetes and Cloud Native Associate Exam (KCNA) +UID:61792 +CREATED:20240229T171308Z +LAST-MODIFIED:20240229T171308Z +END:VEVENT +END:VCALENDAR -- 2.45.2 From 75cacc3e048e87222bcb720e646f3158f0f930fc Mon Sep 17 00:00:00 2001 From: bjt-user Date: Sun, 3 Mar 2024 16:10:12 +0100 Subject: [PATCH 2/3] redacted test file --- tests/start_date_is_first_field.ics | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/start_date_is_first_field.ics b/tests/start_date_is_first_field.ics index 4042033..9aad99d 100644 --- a/tests/start_date_is_first_field.ics +++ b/tests/start_date_is_first_field.ics @@ -3,8 +3,8 @@ BEGIN:VEVENT DTSTART:20240413T070000Z DTEND:20240413T083000Z DTSTAMP:20240229T171200Z -SUMMARY:Kubernetes and Cloud Native Associate Exam (KCNA) -DESCRIPTION:Kubernetes and Cloud Native Associate Exam (KCNA) +SUMMARY:XYZ Exam (XYZ) +DESCRIPTION:XYZ Exam (XYZ) UID:61792 CREATED:20240229T171308Z LAST-MODIFIED:20240229T171308Z -- 2.45.2 From 97208505d8502429970b53656f62ed3a045018c2 Mon Sep 17 00:00:00 2001 From: bjt-user Date: Sun, 3 Mar 2024 16:29:57 +0100 Subject: [PATCH 3/3] fixed bug and created script for running tests --- src/Makefile | 2 +- src/main.c | 3 +++ tests/run_tests.sh | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100755 tests/run_tests.sh diff --git a/src/Makefile b/src/Makefile index 05de544..6985d9e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -39,4 +39,4 @@ test: @echo ./$(EXECUTABLE) -h @echo - ./$(EXECUTABLE) -f ../tests/calendar.ics + ../tests/run_tests.sh diff --git a/src/main.c b/src/main.c index b886522..697f2a6 100644 --- a/src/main.c +++ b/src/main.c @@ -11,6 +11,7 @@ #include #include #include +#include int main(int argc, char **argv) { char *ics_path = ""; @@ -38,6 +39,8 @@ int main(int argc, char **argv) { while(read_until_nl(myfd, my_event)) { if (strncmp(my_event, "BEGIN:VEVENT", 12) == 0) { + // include the BEGIN:EVENT to not loose the new line of first field + lseek(myfd, -12, SEEK_CUR); memset(my_event, '\0', sizeof(my_event)); read_until_string(myfd, my_event, "END:VEVENT"); unfolding_string(my_event, unfolded_event); diff --git a/tests/run_tests.sh b/tests/run_tests.sh new file mode 100755 index 0000000..29f3f20 --- /dev/null +++ b/tests/run_tests.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +mapfile -t files < <(find ../tests/. -name "*.ics") + +i=1 +for file in ${files[@]}; do + echo "TEST ${i}: ${file}" + echo "====================================================" + ../src/icscli -f "${file}" + echo "====================================================" + echo + ((i++)) +done + +exit 0 -- 2.45.2