26 lines
742 B
C++
26 lines
742 B
C++
#include <doctest/doctest.h>
|
|
|
|
#include "fgc/Paths.h"
|
|
|
|
#include <cstdlib>
|
|
|
|
using namespace fgc;
|
|
|
|
TEST_CASE("expandUser expands ~ and environment variables") {
|
|
setenv("HOME", "/home/tester", 1);
|
|
setenv("FOO", "bar", 1);
|
|
|
|
CHECK(paths::expandUser("~/x") == "/home/tester/x");
|
|
CHECK(paths::expandUser("~") == "/home/tester");
|
|
CHECK(paths::expandUser("$FOO/y") == "bar/y");
|
|
CHECK(paths::expandUser("${FOO}z") == "barz");
|
|
CHECK(paths::expandUser("/abs/path") == "/abs/path");
|
|
CHECK(paths::expandUser("") == "");
|
|
}
|
|
|
|
TEST_CASE("configSearchPaths honours the CLI argument first") {
|
|
auto p = paths::configSearchPaths("/explicit/config.ini");
|
|
REQUIRE(!p.empty());
|
|
CHECK(p.front() == "/explicit/config.ini");
|
|
}
|