From 1cef8e27f4b07296217f8a3b5cbe4ce5e517a09e Mon Sep 17 00:00:00 2001 From: Sijmen Huizenga Date: Sat, 30 Sep 2023 19:05:12 +0200 Subject: [PATCH] parsre: fix tzone_offset test Resolves a bug that caused 8 of test cases being skipped in test_parser_tzone_offset Signed-off-by: Sijmen Huizenga --- tests/internal/parser.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/internal/parser.c b/tests/internal/parser.c index 6a560db716c..c4e4f235f98 100644 --- a/tests/internal/parser.c +++ b/tests/internal/parser.c @@ -33,15 +33,16 @@ struct tz_check tz_entries_ok[] = { {"+0000", 0}, {"+00:00", 0}, {"+00:59", 3540}, - {"-0600", -21000}, - {"-06:00", -21000}, + {"-0600", -21600}, + {"-06:00", -21600}, + {"Z", 0}, }; struct tz_check tz_entries_error[] = { {"0000", 0}, {"+00:90", 0}, {"--600", 0}, - {"-06:00", -21000}, + {"foo", 0}, }; /* Time Lookup */ @@ -134,16 +135,18 @@ void test_parser_tzone_offset() /* Valid offsets */ for (i = 0; i < sizeof(tz_entries_ok) / sizeof(struct tz_check); i++) { - t = &tz_entries_ok[0]; + t = &tz_entries_ok[i]; + TEST_CASE(t->val); len = strlen(t->val); ret = flb_parser_tzone_offset(t->val, len, &diff); - TEST_CHECK(ret == 0 && diff == t->diff); + TEST_CHECK(ret == 0); + TEST_CHECK_(diff == t->diff, "expected diff %d but got %d", t->diff, diff); } /* Invalid offsets */ for (i = 0; i < sizeof(tz_entries_error) / sizeof(struct tz_check); i++) { - t = &tz_entries_error[0]; + t = &tz_entries_error[i]; len = strlen(t->val); ret = flb_parser_tzone_offset(t->val, len, &diff);