From: Jonathan Wakely Date: Wed, 15 Nov 2017 18:22:43 +0000 (+0000) Subject: Minor improvements to Filesystem tests X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4e6c42983787bcec345526ab04a4e541e0b0afb2;p=gcc.git Minor improvements to Filesystem tests * testsuite/27_io/filesystem/iterators/directory_iterator.cc: Leave error_code unset. * testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc: Check for past-the-end before dereferencing. * testsuite/experimental/filesystem/iterators/ recursive_directory_iterator.cc: Likewise. From-SVN: r254781 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 5f0bcca83be..70113177074 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,12 @@ 2017-11-15 Jonathan Wakely + * testsuite/27_io/filesystem/iterators/directory_iterator.cc: Leave + error_code unset. + * testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc: + Check for past-the-end before dereferencing. + * testsuite/experimental/filesystem/iterators/ + recursive_directory_iterator.cc: Likewise. + * include/bits/range_access.h (size, empty, data): Add conditional noexcept to generic overloads. diff --git a/libstdc++-v3/testsuite/27_io/filesystem/iterators/directory_iterator.cc b/libstdc++-v3/testsuite/27_io/filesystem/iterators/directory_iterator.cc index c3e6f01670a..9cdbd7aafa0 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/iterators/directory_iterator.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/iterators/directory_iterator.cc @@ -61,7 +61,6 @@ test01() ec = bad_ec; permissions(p, fs::perms::none, ec); VERIFY( !ec ); - ec = bad_ec; iter = fs::directory_iterator(p, ec); VERIFY( ec ); VERIFY( iter == end(iter) ); diff --git a/libstdc++-v3/testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc b/libstdc++-v3/testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc index 1ef450fc907..d41a1506d3b 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc @@ -87,6 +87,7 @@ test01() VERIFY( iter != end(iter) ); VERIFY( iter->path() == p/"d1" ); ++iter; // should recurse into d1 + VERIFY( iter != end(iter) ); VERIFY( iter->path() == p/"d1/d2" ); iter.increment(ec); // should fail to recurse into p/d1/d2 VERIFY( ec ); @@ -99,6 +100,7 @@ test01() VERIFY( iter != end(iter) ); VERIFY( iter->path() == p/"d1" ); ++iter; // should recurse into d1 + VERIFY( iter != end(iter) ); VERIFY( iter->path() == p/"d1/d2" ); ec = bad_ec; iter.increment(ec); // should fail to recurse into p/d1/d2, so skip it diff --git a/libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc b/libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc index 50cc7d45de8..584cfeed839 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc @@ -56,6 +56,7 @@ test01() VERIFY( iter != end(iter) ); VERIFY( iter->path() == p/"d1" ); ++iter; + VERIFY( iter != end(iter) ); VERIFY( iter->path() == p/"d1/d2" ); ++iter; VERIFY( iter == end(iter) ); @@ -88,6 +89,7 @@ test01() VERIFY( iter != end(iter) ); VERIFY( iter->path() == p/"d1" ); ++iter; // should recurse into d1 + VERIFY( iter != end(iter) ); VERIFY( iter->path() == p/"d1/d2" ); iter.increment(ec); // should fail to recurse into p/d1/d2 VERIFY( ec );