summaryrefslogtreecommitdiff
path: root/shared/nm-glib-aux/tests/test-shared-general.c
diff options
context:
space:
mode:
Diffstat (limited to 'shared/nm-glib-aux/tests/test-shared-general.c')
-rw-r--r--shared/nm-glib-aux/tests/test-shared-general.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/shared/nm-glib-aux/tests/test-shared-general.c b/shared/nm-glib-aux/tests/test-shared-general.c
index 02b2f4e1ea..9af5f2b050 100644
--- a/shared/nm-glib-aux/tests/test-shared-general.c
+++ b/shared/nm-glib-aux/tests/test-shared-general.c
@@ -25,6 +25,11 @@ G_STATIC_ASSERT (NM_AF_INET_SIZE == sizeof (in_addr_t));
G_STATIC_ASSERT (NM_AF_INET_SIZE == sizeof (struct in_addr));
G_STATIC_ASSERT (NM_AF_INET6_SIZE == sizeof (struct in6_addr));
+G_STATIC_ASSERT (4 == _nm_alignof (in_addr_t));
+G_STATIC_ASSERT (4 == _nm_alignof (struct in_addr));
+G_STATIC_ASSERT (4 == _nm_alignof (struct in6_addr));
+G_STATIC_ASSERT (4 == _nm_alignof (NMIPAddr));
+
/*****************************************************************************/
static void
@@ -886,6 +891,56 @@ again:
/*****************************************************************************/
+static void
+test_in_strset_ascii_case (void)
+{
+ const char *x;
+
+ x = NULL;
+ g_assert (NM_IN_STRSET_ASCII_CASE (x, NULL));
+ g_assert (NM_IN_STRSET_ASCII_CASE (x, NULL, "b"));
+ g_assert (!NM_IN_STRSET_ASCII_CASE (x, "b"));
+
+ x = "b";
+ g_assert (NM_IN_STRSET (x, "b"));
+ g_assert (NM_IN_STRSET_ASCII_CASE (x, "b"));
+ g_assert (!NM_IN_STRSET (x, "B"));
+ g_assert (NM_IN_STRSET_ASCII_CASE (x, "B"));
+}
+
+/*****************************************************************************/
+
+static void
+test_is_specific_hostname (void)
+{
+ g_assert (!nm_utils_is_specific_hostname (NULL));
+ g_assert (!nm_utils_is_specific_hostname (""));
+ g_assert (!nm_utils_is_specific_hostname ("(none)"));
+ g_assert (nm_utils_is_specific_hostname ("(NONE)"));
+
+ g_assert (!nm_utils_is_specific_hostname ("localhost"));
+ g_assert (!nm_utils_is_specific_hostname ("lOcalHost"));
+ g_assert (!nm_utils_is_specific_hostname ("LOCALHOST"));
+
+ g_assert (!nm_utils_is_specific_hostname ("LOCALHOST.localdomain"));
+
+ g_assert (nm_utils_is_specific_hostname ("xlocalhost"));
+ g_assert (nm_utils_is_specific_hostname ("lOcalHxost"));
+ g_assert (nm_utils_is_specific_hostname ("LOCALxHOST"));
+
+ g_assert (!nm_utils_is_specific_hostname ("foo.LOCALHOST"));
+ g_assert (!nm_utils_is_specific_hostname ("foo.LOCALHOsT6."));
+ g_assert (!nm_utils_is_specific_hostname ("foo.LOCALHOsT6.localdomain6"));
+ g_assert (!nm_utils_is_specific_hostname (".LOCALHOsT6.localdomain6"));
+ g_assert (!nm_utils_is_specific_hostname ("LOCALHOsT6.localdomain6"));
+ g_assert (!nm_utils_is_specific_hostname ("LOCALHOsT6.localdomain6."));
+ g_assert (nm_utils_is_specific_hostname ("LOCALHOsT6.localdomain."));
+
+ g_assert (nm_utils_is_specific_hostname (" "));
+}
+
+/*****************************************************************************/
+
NMTST_DEFINE ();
int main (int argc, char **argv)
@@ -908,6 +963,8 @@ int main (int argc, char **argv)
g_test_add_func ("/general/test_nm_utils_get_next_realloc_size", test_nm_utils_get_next_realloc_size);
g_test_add_func ("/general/test_nm_str_buf", test_nm_str_buf);
g_test_add_func ("/general/test_nm_utils_parse_next_line", test_nm_utils_parse_next_line);
+ g_test_add_func ("/general/test_in_strset_ascii_case", test_in_strset_ascii_case);
+ g_test_add_func ("/general/test_is_specific_hostname", test_is_specific_hostname);
return g_test_run ();
}