diff --git a/unittests/APITests/CMakeLists.txt b/unittests/APITests/CMakeLists.txt index 2ee1473f9..f6d529915 100644 --- a/unittests/APITests/CMakeLists.txt +++ b/unittests/APITests/CMakeLists.txt @@ -1,5 +1,7 @@ set (TESTS - InterruptableConditionVariable) + InterruptableConditionVariable + LexicallyNormal + ) list(APPEND LIBS FEXCore) diff --git a/unittests/APITests/LexicallyNormal.cpp b/unittests/APITests/LexicallyNormal.cpp new file mode 100644 index 000000000..b9d3471c9 --- /dev/null +++ b/unittests/APITests/LexicallyNormal.cpp @@ -0,0 +1,30 @@ +#include +#include +#include + +#define TestPath(Path) \ + REQUIRE(std::string_view(FHU::Filesystem::LexicallyNormal(Path)) == std::string_view(std::filesystem::path(Path).lexically_normal().string())); + +TEST_CASE("LexicallyNormal") { + TestPath(""); + TestPath("/"); + TestPath("/./"); + TestPath("//."); + TestPath("//./"); + TestPath("//.//"); + + TestPath("."); + TestPath(".."); + TestPath(".//"); + TestPath("../../"); + TestPath("././"); + TestPath("./../"); + TestPath("./../"); + TestPath("./.././.././."); + TestPath("./.././.././.."); + + TestPath("./foo/../"); + TestPath("foo/./bar/.."); + TestPath("foo/.///bar/.."); + TestPath("foo/.///bar/../"); +}