mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 07:26:15 +01:00
Improving glib/tests/environment.c
This commit is contained in:
parent
49ec7f18e3
commit
c6ced6abe0
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user