implement and use a platform neutral abstraction of unsetenv(3)

This commit is contained in:
Axel Kohlmeyer
2021-11-03 10:53:10 -04:00
parent 515ef7bece
commit 50f39cd752
5 changed files with 41 additions and 9 deletions

View File

@ -37,7 +37,7 @@ TEST(Platform, clock)
ASSERT_GT(ct_used, 1e-4);
}
TEST(Platform, putenv)
TEST(Platform, putenv_unsetenv)
{
const char *var = getenv("UNITTEST_VAR1");
ASSERT_EQ(var, nullptr);
@ -65,6 +65,14 @@ TEST(Platform, putenv)
ASSERT_THAT(var, StrEq("one=two"));
ASSERT_EQ(platform::putenv(""), -1);
ASSERT_EQ(platform::unsetenv(""), -1);
ASSERT_EQ(platform::unsetenv("UNITTEST_VAR3=two"), -1);
var = getenv("UNITTEST_VAR1");
ASSERT_NE(var, nullptr);
ASSERT_EQ(platform::unsetenv("UNITTEST_VAR1"), 0);
var = getenv("UNITTEST_VAR1");
ASSERT_EQ(var, nullptr);
}
TEST(Platform, list_pathenv)