diff options
Diffstat (limited to 'test/common/str.h')
-rw-r--r-- | test/common/str.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/common/str.h b/test/common/str.h index 72d4df6f61..c4819520d8 100644 --- a/test/common/str.h +++ b/test/common/str.h @@ -157,4 +157,36 @@ class StringTestSuite : public CxxTest::TestSuite TS_ASSERT_EQUALS(str, "TEST IT, NOW! 42"); TS_ASSERT_EQUALS(str2, "Test it, NOW! 42"); } + + void test_lastPathComponent(void) { + TS_ASSERT(Common::lastPathComponent("/", '/') == ""); + TS_ASSERT(Common::lastPathComponent("/foo/bar", '/') == "bar"); + TS_ASSERT(Common::lastPathComponent("/foo//bar/", '/') == "bar"); + TS_ASSERT(Common::lastPathComponent("/foo/./bar", '/') == "bar"); + TS_ASSERT(Common::lastPathComponent("/foo//./bar//", '/') == "bar"); + TS_ASSERT(Common::lastPathComponent("/foo//.bar//", '/') == ".bar"); + + TS_ASSERT(Common::lastPathComponent("", '/') == ""); + TS_ASSERT(Common::lastPathComponent("foo/bar", '/') == "bar"); + TS_ASSERT(Common::lastPathComponent("foo//bar/", '/') == "bar"); + TS_ASSERT(Common::lastPathComponent("foo/./bar", '/') == "bar"); + TS_ASSERT(Common::lastPathComponent("foo//./bar//", '/') == "bar"); + TS_ASSERT(Common::lastPathComponent("foo//.bar//", '/') == ".bar"); + } + + void test_normalizePath(void) { + TS_ASSERT(Common::normalizePath("/", '/') == "/"); + TS_ASSERT(Common::normalizePath("/foo/bar", '/') == "/foo/bar"); + TS_ASSERT(Common::normalizePath("/foo//bar/", '/') == "/foo/bar"); + TS_ASSERT(Common::normalizePath("/foo/./bar", '/') == "/foo/bar"); + TS_ASSERT(Common::normalizePath("/foo//./bar//", '/') == "/foo/bar"); + TS_ASSERT(Common::normalizePath("/foo//.bar//", '/') == "/foo/.bar"); + + TS_ASSERT(Common::normalizePath("", '/') == ""); + TS_ASSERT(Common::normalizePath("foo/bar", '/') == "foo/bar"); + TS_ASSERT(Common::normalizePath("foo//bar/", '/') == "foo/bar"); + TS_ASSERT(Common::normalizePath("foo/./bar", '/') == "foo/bar"); + TS_ASSERT(Common::normalizePath("foo//./bar//", '/') == "foo/bar"); + TS_ASSERT(Common::normalizePath("foo//.bar//", '/') == "foo/.bar"); + } }; |