From 93cc07abd87055e34f8fecd300ef96204e4b9ff2 Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Mon, 18 Oct 2021 14:03:09 +0200 Subject: Tests for ExtendablePathBuilder --- zencore/filesystem.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'zencore/filesystem.cpp') diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index c3edf656e..054ba0ae4 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -887,6 +887,40 @@ TEST_CASE("filesystem") CHECK(Visitor.bFoundExpected); } +TEST_CASE("PathBuilder") +{ +#if ZEN_PLATFORM_WINDOWS + const char* foo_bar = "/foo\\bar"; +#else + const char* foo_bar = "/foo/bar"; +#endif + + ExtendablePathBuilder<32> Path; + for (const char* Prefix : { "/foo", "/foo/" }) + { + Path.Reset(); + Path.Append(Prefix); + Path /= "bar"; + CHECK(Path.ToPath() == foo_bar); + } + + using fspath = std::filesystem::path; + + Path.Reset(); + Path.Append(fspath("/foo/")); + Path /= (fspath("bar")); + CHECK(Path.ToPath() == foo_bar); + +#if ZEN_PLATFORM_WINDOWS + Path.Reset(); + Path.Append(fspath(L"/\u0119oo/")); + Path /= L"bar"; + printf("%ls\n", Path.ToPath().c_str()); + CHECK(Path.ToView() == L"/\u0119oo/bar"); + CHECK(Path.ToPath() == L"\\\u0119oo\\bar"); +# endif +} + #endif } // namespace zen -- cgit v1.2.3