diff options
author | Thomas Haller <thaller@redhat.com> | 2017-05-19 10:32:13 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-05-19 12:45:45 +0200 |
commit | e255ad2a03c84f806f9606b420fa12757bbd883f (patch) | |
tree | 1aebde89bacbc3eeed757b25a7429eeb023255c7 /libnm/tests | |
parent | 8df944c7e495d18bfecaf9d8316ef7783039c94b (diff) | |
download | NetworkManager-e255ad2a03c84f806f9606b420fa12757bbd883f.tar.gz |
libnm: move fixup_desc_string() to nm-libnm-utils.cth/sanitize-non-utf8-rh1443114-pt2
Diffstat (limited to 'libnm/tests')
-rw-r--r-- | libnm/tests/test-general.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/libnm/tests/test-general.c b/libnm/tests/test-general.c index 2653cb913d..7e0b7bb740 100644 --- a/libnm/tests/test-general.c +++ b/libnm/tests/test-general.c @@ -20,15 +20,50 @@ #include "nm-default.h" +#include "nm-libnm-utils.h" + #include "nm-utils/nm-test-utils.h" /*****************************************************************************/ +static void +do_test_fixup_desc_string (const char *desc, const char *expected) +{ + gs_free char *result = NULL; + + result = nm_utils_fixup_desc_string (desc); + g_assert_cmpstr (result, ==, expected); +} + +#define do_test_fixup_desc_string_same(desc) (do_test_fixup_desc_string (""desc"", ""desc"")) + +static void +test_fixup_desc_string (void) +{ + do_test_fixup_desc_string (NULL, NULL); + do_test_fixup_desc_string ("", NULL); + do_test_fixup_desc_string_same ("a"); + do_test_fixup_desc_string_same ("a b"); + do_test_fixup_desc_string ("a b ", "a b"); + do_test_fixup_desc_string (" a bbc ", "a bbc"); + do_test_fixup_desc_string (" a \xcc bbc ", "a bbc"); + do_test_fixup_desc_string (" a\xcc bbc ", "a bbc"); + do_test_fixup_desc_string (" a\xcc""bbc Wireless PC", "a bbc"); + do_test_fixup_desc_string (" a\xcc""bbc Wireless PC ", "a bbc"); + do_test_fixup_desc_string (" a\xcc""bbcWireless PC ", "a bbcWireless PC"); + do_test_fixup_desc_string (" a\xcc""bbc Wireless PCx", "a bbc Wireless PCx"); + do_test_fixup_desc_string (" a\xcc""bbc Inc Wireless PC ", "a bbc"); +} + +/*****************************************************************************/ + NMTST_DEFINE (); int main (int argc, char **argv) { nmtst_init (&argc, &argv, TRUE); + g_test_add_func ("/libnm/general/fixup_desc_string", test_fixup_desc_string); + return g_test_run (); } |