[glib: 1/2] Improving glib/tests/environment.c




commit c6ced6abe0787a2bf1830aff278594d8e7bfa9c0
Author: Emmanuel Fleury <emmanuel fleury gmail com>
Date:   Fri Dec 17 20:18:40 2021 +0100

    Improving glib/tests/environment.c

 glib/tests/environment.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
---
diff --git a/glib/tests/environment.c b/glib/tests/environment.c
index 486acc907..88bc5894a 100644
--- a/glib/tests/environment.c
+++ b/glib/tests/environment.c
@@ -95,6 +95,16 @@ test_getenv (void)
 
   if (g_test_undefined ())
     {
+      g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
+                             "*assertion* != NULL*");
+      g_assert_false (g_setenv (NULL, "baz", TRUE));
+      g_test_assert_expected_messages ();
+
+      g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
+                             "*assertion* != NULL*");
+      g_assert_false (g_setenv ("foo", NULL, TRUE));
+      g_test_assert_expected_messages ();
+
       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
                              "*assertion* == NULL*");
       g_assert_false (g_setenv ("foo=bar", "baz", TRUE));
@@ -111,6 +121,11 @@ test_getenv (void)
 
   if (g_test_undefined ())
     {
+      g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
+                             "*assertion* != NULL*");
+      g_unsetenv (NULL);
+      g_test_assert_expected_messages ();
+
       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
                              "*assertion* == NULL*");
       g_unsetenv ("foo=bar");
@@ -149,9 +164,40 @@ test_environ_array (void)
   env = g_new (gchar *, 1);
   env[0] = NULL;
 
+  if (g_test_undefined ())
+    {
+      g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
+                             "*assertion* != NULL*");
+      g_environ_getenv (env, NULL);
+      g_test_assert_expected_messages ();
+    }
+
   value = g_environ_getenv (env, "foo");
   g_assert (value == NULL);
 
+  if (g_test_undefined ())
+    {
+      g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
+                             "*assertion* != NULL*");
+      env = g_environ_setenv (env, NULL, "bar", TRUE);
+      g_test_assert_expected_messages ();
+
+      g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
+                             "*assertion* == NULL*");
+      env = g_environ_setenv (env, "foo=fuz", "bar", TRUE);
+      g_test_assert_expected_messages ();
+
+      g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
+                             "*assertion* != NULL*");
+      env = g_environ_setenv (env, "foo", NULL, TRUE);
+      g_test_assert_expected_messages ();
+
+      g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
+                             "*assertion* != NULL*");
+      env = g_environ_unsetenv (env, NULL);
+      g_test_assert_expected_messages ();
+    }
+
   env = g_environ_setenv (env, "foo", "bar", TRUE);
   value = g_environ_getenv (env, "foo");
   g_assert_cmpstr (value, ==, "bar");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]