[PATCH] D27310: Handle tests for noexcept that expect a false value

Roger Ferrer Ibanez via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 5 01:31:37 PST 2016


rogfer01 updated this revision to Diff 80235.
rogfer01 added a comment.

- Rewrite the adjusted tests in the way suggested by @EricWF
- Also check that this test works in a GCC-built libcxx


https://reviews.llvm.org/D27310

Files:
  test/libcxx/strings/iterators.exceptions.pass.cpp


Index: test/libcxx/strings/iterators.exceptions.pass.cpp
===================================================================
--- test/libcxx/strings/iterators.exceptions.pass.cpp
+++ test/libcxx/strings/iterators.exceptions.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// XFAIL: libcpp-no-exceptions
 // <iterator>
 
 // __libcpp_is_trivial_iterator<Tp>
@@ -26,6 +25,15 @@
 #include "test_macros.h"
 #include "test_iterators.h"
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
+constexpr bool expected = false;
+#else
+// Under libcpp-no-exceptions all noexcept expressions are trivially true, so
+// any check for a noexcept returning false must actually check for it being
+// true.
+constexpr bool expected = true;
+#endif
+
 int main()
 {
 //  basic tests
@@ -43,17 +51,17 @@
     static_assert(( std::__libcpp_string_gets_noexcept_iterator<std::reverse_iterator<std::__wrap_iter<char *> > > ::value), "");
 
 //  iterators in the libc++ test suite
-    static_assert((!std::__libcpp_string_gets_noexcept_iterator<output_iterator       <char *> >::value), "");
-    static_assert((!std::__libcpp_string_gets_noexcept_iterator<input_iterator        <char *> >::value), "");
-    static_assert((!std::__libcpp_string_gets_noexcept_iterator<forward_iterator      <char *> >::value), "");
-    static_assert((!std::__libcpp_string_gets_noexcept_iterator<bidirectional_iterator<char *> >::value), "");
-    static_assert((!std::__libcpp_string_gets_noexcept_iterator<random_access_iterator<char *> >::value), "");
-    static_assert((!std::__libcpp_string_gets_noexcept_iterator<ThrowingIterator      <char *> >::value), "");
+    static_assert(std::__libcpp_string_gets_noexcept_iterator<output_iterator       <char *> >::value == expected, "");
+    static_assert(std::__libcpp_string_gets_noexcept_iterator<input_iterator        <char *> >::value == expected, "");
+    static_assert(std::__libcpp_string_gets_noexcept_iterator<forward_iterator      <char *> >::value == expected, "");
+    static_assert(std::__libcpp_string_gets_noexcept_iterator<bidirectional_iterator<char *> >::value == expected, "");
+    static_assert(std::__libcpp_string_gets_noexcept_iterator<random_access_iterator<char *> >::value == expected, "");
+    static_assert(std::__libcpp_string_gets_noexcept_iterator<ThrowingIterator      <char *> >::value == expected, "");
 
 #if TEST_STD_VER >= 11
     static_assert(( std::__libcpp_string_gets_noexcept_iterator<NonThrowingIterator   <char *> >::value), "");
 #else
-    static_assert((!std::__libcpp_string_gets_noexcept_iterator<NonThrowingIterator   <char *> >::value), "");
+    static_assert(std::__libcpp_string_gets_noexcept_iterator<NonThrowingIterator   <char *> >::value == expected, "");
 #endif
 
 //


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27310.80235.patch
Type: text/x-patch
Size: 2799 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161205/c4f4df70/attachment.bin>


More information about the cfe-commits mailing list