summaryrefslogtreecommitdiffstats
path: root/test/test_filesystem.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_filesystem.c')
-rw-r--r--test/test_filesystem.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/test_filesystem.c b/test/test_filesystem.c
index 8c7b1ba..a3288ed 100644
--- a/test/test_filesystem.c
+++ b/test/test_filesystem.c
@@ -130,6 +130,28 @@ test_path_parent(void)
}
static void
+test_path_filename(void)
+{
+ // Cases from cppreference.com for std::filesystem::path::filename
+ assert(equals(lilv_path_filename("/foo/bar.txt"), "bar.txt"));
+ assert(equals(lilv_path_filename("/foo/.bar"), ".bar"));
+ assert(equals(lilv_path_filename("/foo/bar/"), ""));
+ assert(equals(lilv_path_filename("/foo/."), "."));
+ assert(equals(lilv_path_filename("/foo/.."), ".."));
+ assert(equals(lilv_path_filename("."), "."));
+ assert(equals(lilv_path_filename(".."), ".."));
+ assert(equals(lilv_path_filename("/"), ""));
+ assert(equals(lilv_path_filename("//host"), "host"));
+
+#ifdef _WIN32
+ assert(equals(lilv_path_filename("C:/foo/bar.txt"), "bar.txt"));
+ assert(equals(lilv_path_filename("C:\\foo\\bar.txt"), "bar.txt"));
+ assert(equals(lilv_path_filename("foo/bar.txt"), "bar.txt"));
+ assert(equals(lilv_path_filename("foo\\bar.txt"), "bar.txt"));
+#endif
+}
+
+static void
test_path_join(void)
{
assert(lilv_path_join(NULL, NULL) == NULL);
@@ -458,6 +480,7 @@ main(void)
test_path_absolute();
test_path_relative_to();
test_path_parent();
+ test_path_filename();
test_path_join();
test_path_canonical();
test_path_exists();