aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2016-05-10 16:39:20 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2016-05-10 16:39:20 +0100
commit7f99d40a99b24026874887aff0cd269370e082f3 (patch)
tree56d73f4ca572513d62c644c4da0f0decca00578e /libstdc++-v3
parent6fe673ad0f0fb412f09ddd219eee1b868cfa19d3 (diff)
downloadgcc-7f99d40a99b24026874887aff0cd269370e082f3.zip
gcc-7f99d40a99b24026874887aff0cd269370e082f3.tar.gz
gcc-7f99d40a99b24026874887aff0cd269370e082f3.tar.bz2
Test begin and end functions for directory iterators
* include/experimental/bits/fs_dir.h (begin, end): Add noexcept. * testsuite/experimental/filesystem/iterators/directory_iterator.cc: Test begin and end functions. * testsuite/experimental/filesystem/iterators/ recursive_directory_iterator.cc: Likewise. From-SVN: r236085
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog6
-rw-r--r--libstdc++-v3/include/experimental/bits/fs_dir.h12
-rw-r--r--libstdc++-v3/testsuite/experimental/filesystem/iterators/directory_iterator.cc26
-rw-r--r--libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc16
4 files changed, 56 insertions, 4 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 614f192..fdcb9ca 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,11 @@
2016-05-10 Jonathan Wakely <jwakely@redhat.com>
+ * include/experimental/bits/fs_dir.h (begin, end): Add noexcept.
+ * testsuite/experimental/filesystem/iterators/directory_iterator.cc:
+ Test begin and end functions.
+ * testsuite/experimental/filesystem/iterators/
+ recursive_directory_iterator.cc: Likewise.
+
PR libstdc++/71038
* src/filesystem/ops.cc (do_copy_file): Fix backwards conditions.
* testsuite/experimental/filesystem/operations/copy_file.cc: New test.
diff --git a/libstdc++-v3/include/experimental/bits/fs_dir.h b/libstdc++-v3/include/experimental/bits/fs_dir.h
index 011d398..70a95eb 100644
--- a/libstdc++-v3/include/experimental/bits/fs_dir.h
+++ b/libstdc++-v3/include/experimental/bits/fs_dir.h
@@ -235,10 +235,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
};
inline directory_iterator
- begin(directory_iterator __iter) { return __iter; }
+ begin(directory_iterator __iter) noexcept
+ { return __iter; }
inline directory_iterator
- end(directory_iterator) { return directory_iterator(); }
+ end(directory_iterator) noexcept
+ { return directory_iterator(); }
inline bool
operator==(const directory_iterator& __lhs, const directory_iterator& __rhs)
@@ -327,10 +329,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
};
inline recursive_directory_iterator
- begin(recursive_directory_iterator __iter) { return __iter; }
+ begin(recursive_directory_iterator __iter) noexcept
+ { return __iter; }
inline recursive_directory_iterator
- end(recursive_directory_iterator) { return recursive_directory_iterator(); }
+ end(recursive_directory_iterator) noexcept
+ { return recursive_directory_iterator(); }
inline bool
operator==(const recursive_directory_iterator& __lhs,
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/iterators/directory_iterator.cc b/libstdc++-v3/testsuite/experimental/filesystem/iterators/directory_iterator.cc
index ce9f437..ffd97ce 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/iterators/directory_iterator.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/iterators/directory_iterator.cc
@@ -113,10 +113,36 @@ test03()
remove_all(p, ec);
}
+void
+test04()
+{
+ bool test __attribute__((unused)) = false;
+
+ const fs::directory_iterator it;
+ VERIFY( it == fs::directory_iterator() );
+}
+
+void
+test05()
+{
+ bool test __attribute__((unused)) = false;
+
+ auto p = __gnu_test::nonexistent_path();
+ create_directory(p);
+ create_directory_symlink(p, p / "l");
+ fs::directory_iterator it(p), endit;
+ VERIFY( begin(it) == it );
+ static_assert( noexcept(begin(it)), "begin is noexcept" );
+ VERIFY( end(it) == endit );
+ static_assert( noexcept(end(it)), "end is noexcept" );
+}
+
int
main()
{
test01();
test02();
test03();
+ test04();
+ test05();
}
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 fb4c31e..b44ff3f 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc
@@ -153,6 +153,21 @@ test04()
VERIFY( it == fs::recursive_directory_iterator() );
}
+void
+test05()
+{
+ bool test __attribute__((unused)) = false;
+
+ auto p = __gnu_test::nonexistent_path();
+ create_directory(p);
+ create_directory_symlink(p, p / "l");
+ fs::recursive_directory_iterator it(p), endit;
+ VERIFY( begin(it) == it );
+ static_assert( noexcept(begin(it)), "begin is noexcept" );
+ VERIFY( end(it) == endit );
+ static_assert( noexcept(end(it)), "end is noexcept" );
+}
+
int
main()
{
@@ -160,4 +175,5 @@ main()
test02();
test03();
test04();
+ test05();
}