Additional tests.

This commit is contained in:
gulrak 2019-05-26 11:08:52 +02:00
parent af4bbe14e1
commit 3ae76b29a0
2 changed files with 17 additions and 9 deletions

View File

@ -2515,6 +2515,7 @@ GHC_INLINE path::iterator::iterator(const path::string_type::const_iterator& fir
} }
else else
#endif #endif
{
if (_first != _last && *_first == '/') { if (_first != _last && *_first == '/') {
if (_last - _first >= 2 && *(_first + 1) == '/' && !(_last - _first >= 3 && *(_first + 2) == '/')) { if (_last - _first >= 2 && *(_first + 1) == '/' && !(_last - _first >= 3 && *(_first + 2) == '/')) {
_root = increment(_first); _root = increment(_first);
@ -2527,6 +2528,7 @@ GHC_INLINE path::iterator::iterator(const path::string_type::const_iterator& fir
_root = _last; _root = _last;
} }
} }
}
GHC_INLINE path::string_type::const_iterator path::iterator::increment(const path::string_type::const_iterator& pos) const 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) GHC_INLINE path::iterator path::iterator::operator--(int)
{ {
path::iterator i{*this}; auto i = *this;
--(*this); --(*this);
return i; return i;
} }

View File

@ -968,13 +968,19 @@ TEST_CASE("30.10.8.5 path iterators", "[filesystem][path][fs.path.itr]")
p2 /= pe; p2 /= pe;
} }
CHECK(p1 == p2); 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()) { if (has_host_root_name_support()) {
CHECK("foo" == *(--fs::path("//host/foo").end())); 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--; pi--;
CHECK("foo" == *pi);*/ CHECK("foo" == *pi);
CHECK("//host" == iterateResult(fs::path("//host"))); CHECK("//host" == iterateResult(fs::path("//host")));
CHECK("//host,/,foo" == iterateResult(fs::path("//host/foo"))); CHECK("//host,/,foo" == iterateResult(fs::path("//host/foo")));
CHECK("//host" == reverseIterateResult(fs::path("//host"))); CHECK("//host" == reverseIterateResult(fs::path("//host")));