aboutsummaryrefslogtreecommitdiff
path: root/libmm-glib/tests
diff options
context:
space:
mode:
Diffstat (limited to 'libmm-glib/tests')
-rw-r--r--libmm-glib/tests/test-common-helpers.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/libmm-glib/tests/test-common-helpers.c b/libmm-glib/tests/test-common-helpers.c
index 69b95cb1..a1a2e61e 100644
--- a/libmm-glib/tests/test-common-helpers.c
+++ b/libmm-glib/tests/test-common-helpers.c
@@ -602,18 +602,40 @@ static void
date_time_iso8601 (void)
{
gchar *date = NULL;
+ GError *error = NULL;
date = mm_new_iso8601_time_from_unix_time (1634307342);
g_assert_cmpstr (date, ==, "2021-10-15T14:15:42Z");
g_free (date);
- date = mm_new_iso8601_time (2021, 10, 15, 16, 15, 42, FALSE, 0);
+ date = mm_new_iso8601_time (2021, 10, 15, 16, 15, 42, FALSE, 0, &error);
+ g_assert_no_error (error);
g_assert_cmpstr (date, ==, "2021-10-15T16:15:42Z");
g_free (date);
- date = mm_new_iso8601_time (2021, 10, 15, 16, 15, 42, TRUE, 120);
+ date = mm_new_iso8601_time (2021, 10, 15, 16, 15, 42, TRUE, 120, &error);
+ g_assert_no_error (error);
g_assert_cmpstr (date, ==, "2021-10-15T16:15:42+02");
g_free (date);
+
+ /* Valid args:
+ * - Year:[1-9999]
+ * - Month:[1-12]
+ * - Day:[1-28|29|30|31] according to year and month
+ * - Hour: [0-23]
+ * - Minute: [0-59]
+ * - Seconds: [0.0-60.0)
+ * */
+ date = mm_new_iso8601_time (2021, 13, 15, 16, 15, 42, TRUE, 120, &error);
+ g_assert_error (error, MM_CORE_ERROR, MM_CORE_ERROR_INVALID_ARGS);
+ g_assert_null (date);
+ g_clear_error (&error);
+
+ /* No February 29 in 2021 */
+ date = mm_new_iso8601_time (2021, 2, 29, 16, 15, 42, TRUE, 120, &error);
+ g_assert_error (error, MM_CORE_ERROR, MM_CORE_ERROR_INVALID_ARGS);
+ g_assert_null (date);
+ g_clear_error (&error);
}
/**************************************************************/