aboutsummaryrefslogtreecommitdiff
path: root/zencore/filesystem.cpp
diff options
context:
space:
mode:
authorMartin Ridgers <[email protected]>2021-10-18 14:03:09 +0200
committerMartin Ridgers <[email protected]>2021-10-18 14:03:09 +0200
commit93cc07abd87055e34f8fecd300ef96204e4b9ff2 (patch)
tree7ba3b3f6a27c894f67ce27f56b82c0e5643dd08f /zencore/filesystem.cpp
parentSimple class for building paths based off an ExtendableString (diff)
downloadzen-93cc07abd87055e34f8fecd300ef96204e4b9ff2.tar.xz
zen-93cc07abd87055e34f8fecd300ef96204e4b9ff2.zip
Tests for ExtendablePathBuilder
Diffstat (limited to 'zencore/filesystem.cpp')
-rw-r--r--zencore/filesystem.cpp34
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