From bd84ba31a589daa311ca6c2bee7ea851660f4274 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 27 Jan 2022 19:04:35 +0100 Subject: glib-aux/tests: add tests for nm_ref_string_equal_str() --- src/libnm-glib-aux/tests/test-shared-general.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libnm-glib-aux/tests/test-shared-general.c b/src/libnm-glib-aux/tests/test-shared-general.c index f12579e363..ecba02e0c2 100644 --- a/src/libnm-glib-aux/tests/test-shared-general.c +++ b/src/libnm-glib-aux/tests/test-shared-general.c @@ -650,12 +650,19 @@ test_nm_ref_string(void) NMRefString *s2; g_assert(NULL == NM_REF_STRING_UPCAST(NULL)); + g_assert(nm_ref_string_equal_str(NULL, NULL)); + g_assert(!nm_ref_string_equal_str(NULL, "")); + g_assert(!nm_ref_string_equal_str(NULL, "a")); s1 = nm_ref_string_new("hallo"); g_assert(s1); g_assert_cmpstr(s1->str, ==, "hallo"); g_assert_cmpint(s1->len, ==, strlen("hallo")); g_assert(s1 == NM_REF_STRING_UPCAST(s1->str)); + g_assert(nm_ref_string_equal_str(s1, "hallo")); + g_assert(!nm_ref_string_equal_str(s1, "hallox")); + g_assert(!nm_ref_string_equal_str(s1, "hall")); + g_assert(!nm_ref_string_equal_str(s1, NULL)); s2 = nm_ref_string_new("hallo"); g_assert(s2 == s1); @@ -672,6 +679,7 @@ test_nm_ref_string(void) g_assert_cmpint(s2->len, ==, NM_STRLEN(STR_WITH_NUL)); g_assert_cmpint(s2->len, >, strlen(s2->str)); g_assert_cmpmem(s2->str, s2->len, STR_WITH_NUL, NM_STRLEN(STR_WITH_NUL)); + g_assert(!nm_ref_string_equal_str(s2, "hallo")); g_assert(s2->str[s2->len] == '\0'); nm_ref_string_unref(s2); } -- cgit v1.2.1