APITests: Test FHU::LexicallyNormal

This commit is contained in:
Ryan Houdek 2023-03-19 02:34:10 -07:00
parent ea275bbdcc
commit 12b710ed16
2 changed files with 33 additions and 1 deletions

View File

@ -1,5 +1,7 @@
set (TESTS
InterruptableConditionVariable)
InterruptableConditionVariable
LexicallyNormal
)
list(APPEND LIBS FEXCore)

View File

@ -0,0 +1,30 @@
#include <catch2/catch.hpp>
#include <filesystem>
#include <FEXHeaderUtils/Filesystem.h>
#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/../");
}