From b2dbcb55e2832c373fecb4033a3ed77e5dbc77aa Mon Sep 17 00:00:00 2001 From: Dominick Allen Date: Mon, 21 Oct 2024 12:49:43 -0500 Subject: Add vector and option. --- test/test_fud.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'test/test_fud.cpp') diff --git a/test/test_fud.cpp b/test/test_fud.cpp index 0778f98..72d569a 100644 --- a/test/test_fud.cpp +++ b/test/test_fud.cpp @@ -15,10 +15,11 @@ * limitations under the License. */ -#include "fud_version.hpp" +#include "fud_config.hpp" #include "libfud.hpp" #include "gtest/gtest.h" +#include namespace fud { @@ -32,11 +33,33 @@ TEST(FudTest, FudFud) auto compareResult = compareMem( fudInfo.revision.data(), fudInfo.revision.size(), - GitHash, + FudGitHash, fudInfo.revision.size() - 1); ASSERT_TRUE(compareResult.isOkay()); EXPECT_EQ(compareResult.getOkay(), 0); EXPECT_EQ(fudInfo.revision[fudInfo.revision.size() - 1], '\0'); } +TEST(FudTest, GetEnv) +{ + constexpr const char* testVarName = "FUD_TEST_VAR"; + constexpr const char* testVarValue = "FUD_TEST_VALUE"; + + ASSERT_EQ(unsetenv(testVarName), 0); + + auto fudVarResult = getEnv(nullptr); + ASSERT_TRUE(fudVarResult.isError()); + ASSERT_EQ(fudVarResult.getError(), FudStatus::NullPointer); + + fudVarResult = getEnv(testVarName); + ASSERT_TRUE(fudVarResult.isError()); + ASSERT_EQ(fudVarResult.getError(), FudStatus::NotFound); + + ASSERT_EQ(setenv(testVarName, testVarValue, 1), 0); + fudVarResult = getEnv(testVarName); + ASSERT_TRUE(fudVarResult.isOkay()); + auto fudVar{fudVarResult.takeOkay()}; + ASSERT_STREQ(fudVar.c_str(), testVarValue); +} + } // namespace fud -- cgit v1.2.3