All checks were successful
Linux unit tests / unit-tests (push) Successful in 30s
40 lines
1.8 KiB
C++
40 lines
1.8 KiB
C++
#include "test_support.hpp"
|
|
|
|
#include <izo/Environment.hpp>
|
|
#include <izo/Paths.hpp>
|
|
|
|
#include <array>
|
|
|
|
int main() {
|
|
std::string error;
|
|
CHECK(izo::SetEnvVar("IZO_TEST_VALUE", "hello-utf8-å", &error));
|
|
CHECK(izo::GetEnvVar("IZO_TEST_VALUE") == "hello-utf8-å");
|
|
CHECK(izo::SetEnvVar("IZO_TEST_VALUE", "", &error));
|
|
CHECK(izo::GetEnvVar("IZO_TEST_VALUE") == "");
|
|
CHECK(izo::UnsetEnvVar("IZO_TEST_VALUE", &error));
|
|
CHECK(!izo::GetEnvVar("IZO_TEST_VALUE"));
|
|
|
|
const auto root = test_directory("paths");
|
|
CHECK(izo::SetEnvVar("HOME", root.string(), &error));
|
|
CHECK(izo::UnsetEnvVar("XDG_DATA_HOME", &error));
|
|
CHECK(izo::UnsetEnvVar("XDG_CONFIG_HOME", &error));
|
|
CHECK(izo::UnsetEnvVar("XDG_CACHE_HOME", &error));
|
|
CHECK(izo::UnsetEnvVar("TMPDIR", &error));
|
|
|
|
CHECK(izo::GetKnownPath(izo::KnownPath::AppData) == root / ".local/share");
|
|
CHECK(izo::GetKnownPath(izo::KnownPath::LocalAppData) == root / ".local/share");
|
|
CHECK(izo::GetKnownPath(izo::KnownPath::Config) == root / ".config");
|
|
CHECK(izo::GetKnownPath(izo::KnownPath::Cache) == root / ".cache");
|
|
CHECK(izo::GetKnownPath(izo::KnownPath::Documents) == root / "Documents");
|
|
CHECK(izo::GetKnownPath(izo::KnownPath::Downloads) == root / "Downloads");
|
|
CHECK(izo::GetKnownPath(izo::KnownPath::Desktop) == root / "Desktop");
|
|
CHECK(izo::GetKnownPath(izo::KnownPath::Temporary) == "/tmp");
|
|
CHECK(!izo::GetKnownPath(izo::KnownPath::ExecutableDirectory, &error).empty());
|
|
CHECK(izo::GetKnownPath(izo::KnownPath::CurrentDirectory, &error) ==
|
|
std::filesystem::current_path());
|
|
|
|
CHECK(izo::SetEnvVar("XDG_CONFIG_HOME", (root / "custom-config").string(), &error));
|
|
CHECK(izo::GetKnownPath(izo::KnownPath::Config) == root / "custom-config");
|
|
std::filesystem::remove_all(root);
|
|
}
|