From 56ce5687567150b0b2cc3e57540d564793ef6bf7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 28 Apr 2015 16:13:54 +0200 Subject: Add support for iteration over path components --- tests/build/path/driver.cxx | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tests/build/path') diff --git a/tests/build/path/driver.cxx b/tests/build/path/driver.cxx index 739146b..3aa624c 100644 --- a/tests/build/path/driver.cxx +++ b/tests/build/path/driver.cxx @@ -77,6 +77,40 @@ main () assert (path ("C:\\foo.txt").base ().string () == "C:\\foo"); #endif + // iteration + // + { + path p; + assert (p.begin () == p.end ()); + } + { + path p ("foo"); + path::iterator i (p.begin ()); + assert (i != p.end () && *i == "foo"); + assert (++i == p.end ()); + } + { + path p ("foo/bar"); + path::iterator i (p.begin ()); + assert (i != p.end () && *i == "foo"); + assert (++i != p.end () && *i == "bar"); + assert (++i == p.end ()); + } + { + path p ("/foo/bar"); + path::iterator i (p.begin ()); + assert (i != p.end () && *i == ""); + assert (++i != p.end () && *i == "foo"); + assert (++i != p.end () && *i == "bar"); + assert (++i == p.end ()); + } + { + path p ("/"); + path::iterator i (p.begin ()); + assert (i != p.end () && *i == ""); + assert (++i == p.end ()); + } + // operator/ // #ifndef _WIN32 -- cgit v1.1