X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=tests%2Fpath.cpp;h=fbb5ff54588685527080faa9991ed94b14e4b8fb;hp=fe85ab89c60585759f6410d5557f1773cab58648;hb=242a4a9abe1e1113b5eb39aa751aa054f696d7be;hpb=3e7b397e47dd371616b0633ceb851c8bd8e2abfa diff --git a/tests/path.cpp b/tests/path.cpp index fe85ab8..fbb5ff5 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,12 +30,15 @@ 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::indexing, "Indexing"); + add(&PathTests::invalid_index, "Invalid index").expect_throw(); } void PathTests::empty() { EXPECT(FS::Path().empty()); + EXPECT(FS::Path("").empty()); EXPECT(!FS::Path(".").empty()); } @@ -95,6 +101,24 @@ 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::indexing() { FS::Path path("/foo/bar"); @@ -103,3 +127,9 @@ void PathTests::indexing() EXPECT_EQUAL(path[1], "foo"); EXPECT_EQUAL(path[-1], "bar"); } + +void PathTests::invalid_index() +{ + FS::Path path("foo"); + path[3]; +}