1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-11-17 07:46:03 +00:00

test: Add util tests

Unit test the `get_protocol_from_address()` function family.
This commit is contained in:
Evangelos Ribeiro Tzaras 2021-04-30 16:24:07 +02:00
parent 1e84812938
commit 503e5c2154
2 changed files with 48 additions and 0 deletions

View file

@ -111,4 +111,16 @@ t = executable('account', test_sources,
) )
test('account', t, env: test_env) test('account', t, env: test_env)
test_sources = [ 'test-util.c' ]
t = executable('util', test_sources,
c_args : test_cflags,
link_args: test_link_args,
link_with : [calls_vala, libcalls],
dependencies: calls_deps,
include_directories : [
calls_includes,
]
)
test('util', t, env: test_env)
endif endif

36
tests/test-util.c Normal file
View file

@ -0,0 +1,36 @@
/*
* Copyright (C) 2021 Purism SPC
*
* SPDX-License-Identifier: GPL-3.0+
*
* Author: Evangelos Ribeiro Tzaras <evangelos.tzaras@puri.sm>
*/
#include "util.h"
#include <gtk/gtk.h>
static void
test_protocol_prefix ()
{
g_assert_cmpstr (get_protocol_from_address ("sip:alice@example.org"), ==, "sip");
g_assert_cmpstr (get_protocol_from_address ("SIP:alice@example.org"), ==, "sip");
g_assert_cmpstr (get_protocol_from_address ("sips:bob@example.org"), ==, "sips");
g_assert_cmpstr (get_protocol_from_address ("sIpS:bob@example.org"), ==, "sips");
g_assert_cmpstr (get_protocol_from_address ("tel:+49123456789"), ==, "tel");
g_assert_cmpstr (get_protocol_from_address ("+49123456789"), ==, NULL);
g_assert_cmpstr (get_protocol_from_address_with_fallback ("+49123456789"), ==, "tel");
g_assert_cmpstr (get_protocol_from_address ("mailto:charley@spam.com"), ==, NULL);
}
int
main (int argc,
char *argv[])
{
gtk_test_init (&argc, &argv, NULL);
g_test_add_func ("/Calls/util/protocol_prefix", (GTestFunc) test_protocol_prefix);
g_test_run ();
}