From 3ae76b29a0745319d2a64e34bdbcb35264ad3e99 Mon Sep 17 00:00:00 2001 From: gulrak Date: Sun, 26 May 2019 11:08:52 +0200 Subject: [PATCH] Additional tests. --- include/ghc/filesystem.hpp | 16 +++++++++------- test/filesystem_test.cpp | 10 ++++++++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index 58cc8a0..c26c9a9 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -2515,17 +2515,19 @@ GHC_INLINE path::iterator::iterator(const path::string_type::const_iterator& fir } else #endif + { if (_first != _last && *_first == '/') { - if (_last - _first >= 2 && *(_first + 1) == '/' && !(_last - _first >= 3 && *(_first + 2) == '/')) { - _root = increment(_first); + if (_last - _first >= 2 && *(_first + 1) == '/' && !(_last - _first >= 3 && *(_first + 2) == '/')) { + _root = increment(_first); + } + else { + _root = _first; + } } else { - _root = _first; + _root = _last; } } - else { - _root = _last; - } } GHC_INLINE path::string_type::const_iterator path::iterator::increment(const path::string_type::const_iterator& pos) const @@ -2631,7 +2633,7 @@ GHC_INLINE path::iterator& path::iterator::operator--() GHC_INLINE path::iterator path::iterator::operator--(int) { - path::iterator i{*this}; + auto i = *this; --(*this); return i; } diff --git a/test/filesystem_test.cpp b/test/filesystem_test.cpp index 3c13eff..c846b6c 100644 --- a/test/filesystem_test.cpp +++ b/test/filesystem_test.cpp @@ -968,13 +968,19 @@ TEST_CASE("30.10.8.5 path iterators", "[filesystem][path][fs.path.itr]") p2 /= pe; } CHECK(p1 == p2); + CHECK("bar" == *(--fs::path("/foo/bar").end())); + auto p = fs::path("/foo/bar"); + auto pi = p.end(); + pi--; + CHECK("bar" == *pi); } if (has_host_root_name_support()) { CHECK("foo" == *(--fs::path("//host/foo").end())); - /*auto pi = fs::path("//host/foo").end(); + auto p = fs::path("//host/foo"); + auto pi = p.end(); pi--; - CHECK("foo" == *pi);*/ + CHECK("foo" == *pi); CHECK("//host" == iterateResult(fs::path("//host"))); CHECK("//host,/,foo" == iterateResult(fs::path("//host/foo"))); CHECK("//host" == reverseIterateResult(fs::path("//host")));