diff options
Diffstat (limited to 'zencore/filesystem.cpp')
| -rw-r--r-- | zencore/filesystem.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
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 |