void concatenation();
void iterator_abs();
void iterator_rel();
+ void iterator_special();
+ void invalid_iterator();
void indexing();
+ void invalid_index();
};
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()
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");
EXPECT_EQUAL(path[1], "foo");
EXPECT_EQUAL(path[-1], "bar");
}
+
+void PathTests::invalid_index()
+{
+ FS::Path path("foo");
+ path[3];
+}