summaryrefslogtreecommitdiff
path: root/test/utils/cpp/path.test.cpp
blob: b0e7eff8cd43486277db36a5018391fb354d44d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <filesystem>

#include "catch2/catch.hpp"
#include "src/utils/cpp/path.hpp"

TEST_CASE("normalization", "[path]") {
    CHECK(ToNormalPath(std::filesystem::path{""}) ==
          ToNormalPath(std::filesystem::path{"."}));
    CHECK(ToNormalPath(std::filesystem::path{""}).string() == ".");
    CHECK(ToNormalPath(std::filesystem::path{"."}).string() == ".");

    CHECK(ToNormalPath(std::filesystem::path{"foo/bar/.."}).string() == "foo");
    CHECK(ToNormalPath(std::filesystem::path{"foo/bar/../"}).string() == "foo");
    CHECK(ToNormalPath(std::filesystem::path{"foo/bar/../baz"}).string() ==
          "foo/baz");
    CHECK(ToNormalPath(std::filesystem::path{"./foo/bar"}).string() ==
          "foo/bar");
    CHECK(ToNormalPath(std::filesystem::path{"foo/.."}).string() == ".");
    CHECK(ToNormalPath(std::filesystem::path{"./foo/.."}).string() == ".");
}