aboutsummaryrefslogtreecommitdiff
path: root/test/common/str.h
diff options
context:
space:
mode:
authorMax Horn2008-09-02 11:32:38 +0000
committerMax Horn2008-09-02 11:32:38 +0000
commit155b8606c1a798f89078aa39780a8b4c28161da7 (patch)
tree5c28bf3781de8a610f7fcd7953cd312e6432da12 /test/common/str.h
parent9c5d81fb831706aae3cc0ec001aec9f0f8d0439f (diff)
downloadscummvm-rg350-155b8606c1a798f89078aa39780a8b4c28161da7.tar.gz
scummvm-rg350-155b8606c1a798f89078aa39780a8b4c28161da7.tar.bz2
scummvm-rg350-155b8606c1a798f89078aa39780a8b4c28161da7.zip
Added two new global funcs which ease proper handling of 'path' strings: Common::lastPathComponent() and Common::normalizePath()
svn-id: r34272
Diffstat (limited to 'test/common/str.h')
-rw-r--r--test/common/str.h32
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");
+ }
};