tests: Add some missing GDateTime ISO8601 parsing tests

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 <pwithnall@gnome.org>
This commit is contained in:
Philip Withnall 2025-02-18 18:20:56 +00:00
parent 4c56ff8034
commit 7f6d81130e
No known key found for this signature in database
GPG Key ID: C5C42CFB268637CA

View File

@ -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 {