implement platform abstraction of unsetenv()

This commit is contained in:
Axel Kohlmeyer
2021-10-22 11:05:32 -04:00
parent 69f5e1feac
commit 5c9a4f4be0
5 changed files with 41 additions and 6 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)