From f98f2871decb2219fef481f775ddacb7b56392e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sat, 4 Oct 2025 12:27:46 +0200 Subject: [PATCH] emergency-call-types: Test get_numbers_by_country_code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Guido Günther Part-of: --- tests/test-emergency-call-types.c | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/test-emergency-call-types.c b/tests/test-emergency-call-types.c index 242e672..9080738 100644 --- a/tests/test-emergency-call-types.c +++ b/tests/test-emergency-call-types.c @@ -47,6 +47,38 @@ test_lookup (void) g_free (lookup); } + +static void +test_country (void) +{ + GStrv result = NULL; + const char *const expected_xx[] = { "114", "117", "118", NULL }; + + /* Hit the built in fallbacks */ + result = calls_emergency_call_types_get_numbers_by_country_code ("de"); + g_assert_cmpint (g_strv_length (result), ==, 1); + g_strfreev (result); + + /* Hit the test data */ + result = calls_emergency_call_types_get_numbers_by_country_code ("xx"); + g_assert_cmpint (g_strv_length (result), ==, 3); + g_assert_cmpstrv (result, expected_xx); + g_strfreev (result); + + /* Hit the test data */ + result = calls_emergency_call_types_get_numbers_by_country_code ("yy"); + g_assert_cmpint (g_strv_length (result), ==, 1); + g_strfreev (result); + + /* Hit the test data */ + result = calls_emergency_call_types_get_numbers_by_country_code ("zz"); + g_assert_null (result); + + result = calls_emergency_call_types_get_numbers_by_country_code ("doesnotexist"); + g_assert_null (result); +} + + int main (int argc, char *argv[]) @@ -57,6 +89,7 @@ main (int argc, calls_emergency_call_types_init (TEST_DATABASE); g_test_add_func ("/Calls/EmergencyCallTypes/lookup", test_lookup); + g_test_add_func ("/Calls/EmergencyCallTypes/country", test_country); ret = g_test_run ();