From 7f6d81130ec05406a8820bc753ed03859e88daea Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 18 Feb 2025 18:20:56 +0000 Subject: [PATCH] tests: Add some missing GDateTime ISO8601 parsing tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This improves test coverage, adding coverage for some lines which I spotted were not covered while testing the preceding commits. It doesn’t directly test the preceding commits, though. Signed-off-by: Philip Withnall --- glib/tests/gdatetime.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/glib/tests/gdatetime.c b/glib/tests/gdatetime.c index 9e1acd097..94dd028a3 100644 --- a/glib/tests/gdatetime.c +++ b/glib/tests/gdatetime.c @@ -866,6 +866,23 @@ test_GDateTime_new_from_iso8601 (void) * NaN */ dt = g_date_time_new_from_iso8601 ("0005306 000001,666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666600080000-00", NULL); g_assert_null (dt); + + /* Various invalid timezone offsets which look like they could be in + * `+hh:mm`, `-hh:mm`, `+hhmm`, `-hhmm`, `+hh` or `-hh` format */ + dt = g_date_time_new_from_iso8601 ("2025-02-18T18:14:00+01:xx", NULL); + g_assert_null (dt); + dt = g_date_time_new_from_iso8601 ("2025-02-18T18:14:00+xx:00", NULL); + g_assert_null (dt); + dt = g_date_time_new_from_iso8601 ("2025-02-18T18:14:00+xx:xx", NULL); + g_assert_null (dt); + dt = g_date_time_new_from_iso8601 ("2025-02-18T18:14:00+01xx", NULL); + g_assert_null (dt); + dt = g_date_time_new_from_iso8601 ("2025-02-18T18:14:00+xx00", NULL); + g_assert_null (dt); + dt = g_date_time_new_from_iso8601 ("2025-02-18T18:14:00+xxxx", NULL); + g_assert_null (dt); + dt = g_date_time_new_from_iso8601 ("2025-02-18T18:14:00+xx", NULL); + g_assert_null (dt); } typedef struct {