]> git.tdb.fi Git - libs/core.git/commitdiff
Add some more test cases for FS::Path
authorMikko Rasa <tdb@tdb.fi>
Fri, 6 Jul 2012 20:22:19 +0000 (23:22 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 6 Jul 2012 20:22:19 +0000 (23:22 +0300)
tests/path.cpp

index fe85ab89c60585759f6410d5557f1773cab58648..0811c49a28457c35f6d2fa04fbf2d7d2d4962c5d 100644 (file)
@@ -17,7 +17,10 @@ private:
        void concatenation();
        void iterator_abs();
        void iterator_rel();
+       void iterator_special();
+       void invalid_iterator();
        void indexing();
+       void invalid_index();
 };
 
 PathTests::PathTests()
@@ -27,7 +30,10 @@ PathTests::PathTests()
        add(&PathTests::concatenation, "Concatenation");
        add(&PathTests::iterator_abs, "Iterator (absolute path)");
        add(&PathTests::iterator_rel, "Iterator (relative path)");
+       add(&PathTests::iterator_special, "Iterator (special cases)");
+       add(&PathTests::invalid_iterator, "Invalid iterator").expect_throw<logic_error>();
        add(&PathTests::indexing, "Indexing");
+       add(&PathTests::invalid_index, "Invalid index").expect_throw<invalid_argument>();
 }
 
 void PathTests::empty()
@@ -95,6 +101,30 @@ void PathTests::iterator_rel()
        EXPECT(iter==path.end());
 }
 
+void PathTests::iterator_special()
+{
+       FS::Path path;
+       EXPECT(path.begin()==path.end());
+
+       path = ".";
+       FS::Path::Iterator iter = path.begin();
+       EXPECT_EQUAL(*iter, ".");
+       ++iter;
+       EXPECT(iter==path.end());
+
+       path = "/";
+       iter = path.begin();
+       EXPECT_EQUAL(*iter, "/");
+       ++iter;
+       EXPECT(iter==path.end());
+}
+
+void PathTests::invalid_iterator()
+{
+       FS::Path path("foo");
+       *path.end();
+}
+
 void PathTests::indexing()
 {
        FS::Path path("/foo/bar");
@@ -103,3 +133,9 @@ void PathTests::indexing()
        EXPECT_EQUAL(path[1], "foo");
        EXPECT_EQUAL(path[-1], "bar");
 }
+
+void PathTests::invalid_index()
+{
+       FS::Path path("foo");
+       path[3];
+}