diff options
| author | ruki <[email protected]> | 2026-01-21 22:09:09 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-01-21 22:09:09 +0800 |
| commit | 197dfb660a35825d0bb46f8ef69884d7ec00c410 (patch) | |
| tree | 271f4bce14ac31a35f89c7df2e51c27b27025043 /tests/modules/path/test.lua | |
| parent | 3a602442ced657fd07d9890176f1bc24ea1b346f (diff) | |
fix path.filename and lastof
Diffstat (limited to 'tests/modules/path/test.lua')
| -rw-r--r-- | tests/modules/path/test.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/modules/path/test.lua b/tests/modules/path/test.lua index f68a57e5f..57f7d06bc 100644 --- a/tests/modules/path/test.lua +++ b/tests/modules/path/test.lua @@ -34,6 +34,23 @@ function test_extension(t) t:are_equal(path.extension("\\home\\foo.so"), ".so") end +function test_filename(t) + t:are_equal(path.filename("foo"), "foo") + t:are_equal(path.filename("foo.so"), "foo.so") + t:are_equal(path.filename("/tmp/foo.so"), "foo.so") + t:are_equal(path.filename("c:\\tmp\\foo.so"), "foo.so") + t:are_equal(path.filename("/tmp/.."), "..") + t:are_equal(path.filename("/tmp/."), ".") + t:are_equal(path.filename("/"), "") + t:are_equal(path.filename(""), "") + + -- unicode + t:are_equal(path.filename("Unicode 测试/test.lua"), "test.lua") + t:are_equal(path.filename("Unicode 测试/foo/test.lua"), "test.lua") + t:are_equal(path.filename("测试/test.lua"), "test.lua") + t:are_equal(path.filename("测试\\test.lua"), "test.lua") +end + function test_directory(t) t:are_equal(path.directory(""), nil) t:are_equal(path.directory("."), nil) |
