Resolve emergency number types

We add a small hardcoded table for now. Future versions
will improve this to parse this out of ASOPs eccdata.

If we can't determine the type of a number we add it verbatim.
This commit is contained in:
Guido Günther
2022-12-21 19:13:25 +01:00
committed by Evangelos Ribeiro Tzaras
parent 9f68e242fd
commit b087bea16b
7 changed files with 211 additions and 4 deletions

View File

@@ -38,6 +38,20 @@ test_includes = include_directories('.')
subdir('mock')
subdir('services')
test_sources = [ 'test-emergency-call-types.c' ]
t = executable('emergency-call-types', test_sources,
c_args : test_cflags,
link_args: test_link_args,
pie: true,
link_with : [calls_vala, libcalls],
dependencies: calls_deps,
include_directories : [
calls_includes,
]
)
test('emergency-call-types', t, env: test_env)
test_sources = [ 'test-manager.c' ]
t = executable('manager', test_sources,

View File

@@ -0,0 +1,52 @@
/*
* Copyright (C) Guido Günther
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include "calls-emergency-call-types.h"
#include <glib.h>
static void
test_lookup (void)
{
char *lookup = NULL;
/* No countyr code -> no match */
lookup = calls_emergency_call_type_get_name ("112", NULL);
g_assert_null (lookup);
/* Country code that's not in the table */
lookup = calls_emergency_call_type_get_name ("112", "doesnotexist");
g_assert_null (lookup);
/* Numbers that match a single type */
lookup = calls_emergency_call_type_get_name ("117", "CH");
g_assert_cmpstr (lookup, ==, "Police");
g_free (lookup);
lookup = calls_emergency_call_type_get_name ("144", "CH");
g_assert_cmpstr (lookup, ==, "Ambulance");
g_free (lookup);
/* Numbers that match multiple types */
lookup = calls_emergency_call_type_get_name ("112", "DE");
g_assert_cmpstr (lookup, ==, "Police, Ambulance, Fire Brigade");
g_free (lookup);
/* Numbers that doesn't match */
lookup = calls_emergency_call_type_get_name ("123456", "DE");
g_assert_null (lookup);
}
int
main (int argc,
char *argv[])
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/Calls/EmergencyCallTypes/lookup", test_lookup);
return g_test_run ();
}