From 97208505d8502429970b53656f62ed3a045018c2 Mon Sep 17 00:00:00 2001 From: bjt-user Date: Sun, 3 Mar 2024 16:29:57 +0100 Subject: [PATCH] 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