summaryrefslogtreecommitdiff
path: root/test/test_fud.cpp
diff options
context:
space:
mode:
authorDominick Allen <djallen@librehumanitas.org>2024-10-21 12:49:43 -0500
committerDominick Allen <djallen@librehumanitas.org>2024-10-21 12:49:43 -0500
commitb2dbcb55e2832c373fecb4033a3ed77e5dbc77aa (patch)
tree1f294fcf1d85a02db86de3eea2b03393fd89ca5a /test/test_fud.cpp
parent6a27a2a4032e88fa9154ef0f0741edc584f7a701 (diff)
Add vector and option.
Diffstat (limited to 'test/test_fud.cpp')
-rw-r--r--test/test_fud.cpp27
1 files changed, 25 insertions, 2 deletions
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 <cstdlib>
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