aboutsummaryrefslogtreecommitdiff
path: root/test/filepath.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/filepath.cpp')
-rw-r--r--test/filepath.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/filepath.cpp b/test/filepath.cpp
index 81a26eb4..a0d05ba3 100644
--- a/test/filepath.cpp
+++ b/test/filepath.cpp
@@ -41,6 +41,14 @@ TEST_CASE("push() adds a new component to the path", "[Filepath]")
REQUIRE(dir == Filepath::from_locale_string("/tmp/newsboat/.local/share/cache/cache.db"));
}
+TEST_CASE("push() still adds a separator to non-empty path if new component is empty",
+ "[Filepath]")
+{
+ auto dir = Filepath::from_locale_string("/root");
+ dir.push(Filepath::from_locale_string(""));
+ REQUIRE(dir.display() == "/root/");
+}
+
TEST_CASE("Can be extended with join()", "[Filepath]")
{
const auto tmp = Filepath::from_locale_string("/tmp");
@@ -52,6 +60,14 @@ TEST_CASE("Can be extended with join()", "[Filepath]")
REQUIRE(subdir == Filepath::from_locale_string("/tmp/newsboat/tests"));
}
+TEST_CASE("join() still adds a separator to non-empty path if new component is empty",
+ "[Filepath]")
+{
+ const auto path = Filepath::from_locale_string("relative path");
+ const auto path_with_trailing_slash = path.join(Filepath{});
+ REQUIRE(path_with_trailing_slash.display() == "relative path/");
+}
+
TEST_CASE("Can be copied", "[Filepath]")
{
auto original = Filepath::from_locale_string("/etc/hosts");