From 96dadad38bc0b114174a7d4a707cdd8e88fce3aa Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 6 Jul 2012 23:22:19 +0300 Subject: [PATCH] Add some more test cases for FS::Path --- tests/path.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/path.cpp b/tests/path.cpp index fe85ab8..0811c49 100644 --- a/tests/path.cpp +++ b/tests/path.cpp @@ -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(); add(&PathTests::indexing, "Indexing"); + add(&PathTests::invalid_index, "Invalid index").expect_throw(); } 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]; +} -- 2.45.2