rogfer01 updated the summary for this revision.
rogfer01 updated this revision to Diff 76532.
rogfer01 added a comment.

Update tests following Marshall's suggestion to avoid too much code 
duplication. Also add assert(false) after the throwing action to ensure that 
the expected exception is actually thrown.


https://reviews.llvm.org/D26136

Files:
  test/std/strings/basic.string/string.access/at.pass.cpp
  test/std/strings/basic.string/string.capacity/reserve.pass.cpp
  test/std/strings/basic.string/string.capacity/resize_size.pass.cpp
  test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp
  test/std/strings/basic.string/string.cons/substr.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp
  test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp
  test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/size_T_size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp

Index: test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp
+++ test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // int compare(size_type pos1, size_type n1, const basic_string& str,
@@ -20,6 +19,8 @@
 
 #include "min_allocator.h"
 
+#include "test_macros.h"
+
 int sign(int x)
 {
     if (x == 0)
@@ -34,33 +35,45 @@
 test(const S& s,   typename S::size_type pos1, typename S::size_type n1,
      const S& str, typename S::size_type pos2, typename S::size_type n2, int x)
 {
-    try
-    {
+    if (pos1 <= s.size() && pos2 <= str.size())
         assert(sign(s.compare(pos1, n1, str, pos2, n2)) == sign(x));
-        assert(pos1 <= s.size());
-        assert(pos2 <= str.size());
-    }
-    catch (const std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos1 > s.size() || pos2 > str.size());
+        try
+        {
+            s.compare(pos1, n1, str, pos2, n2);
+            assert(false);
+        }
+        catch (const std::out_of_range&)
+        {
+            assert(pos1 > s.size() || pos2 > str.size());
+        }
     }
+#endif
 }
 
 template <class S>
 void
 test_npos(const S& s,   typename S::size_type pos1, typename S::size_type n1,
           const S& str, typename S::size_type pos2, int x)
 {
-    try
-    {
+    if (pos1 <= s.size() && pos2 <= str.size())
         assert(sign(s.compare(pos1, n1, str, pos2)) == sign(x));
-        assert(pos1 <= s.size());
-        assert(pos2 <= str.size());
-    }
-    catch (const std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos1 > s.size() || pos2 > str.size());
+        try
+        {
+            s.compare(pos1, n1, str, pos2);
+            assert(false);
+        }
+        catch (const std::out_of_range&)
+        {
+            assert(pos1 > s.size() || pos2 > str.size());
+        }
     }
+#endif
 }
 
 template <class S>
Index: test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp
+++ test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // int compare(size_type pos1, size_type n1, const basic_string& str) const;
@@ -18,6 +17,8 @@
 
 #include "min_allocator.h"
 
+#include "test_macros.h"
+
 int sign(int x)
 {
     if (x == 0)
@@ -32,15 +33,22 @@
 test(const S& s, typename S::size_type pos1, typename S::size_type n1,
      const S& str, int x)
 {
-    try
-    {
+    if (pos1 <= s.size())
         assert(sign(s.compare(pos1, n1, str)) == sign(x));
-        assert(pos1 <= s.size());
-    }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos1 > s.size());
+        try
+        {
+            s.compare(pos1, n1, str);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos1 > s.size());
+        }
     }
+#endif
 }
 
 template <class S>
Index: test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp
+++ test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // int compare(size_type pos, size_type n1, const charT *s, size_type n2) const;
@@ -18,6 +17,8 @@
 
 #include "min_allocator.h"
 
+#include "test_macros.h"
+
 int sign(int x)
 {
     if (x == 0)
@@ -32,15 +33,22 @@
 test(const S& s, typename S::size_type pos, typename S::size_type n1,
      const typename S::value_type* str, typename S::size_type n2, int x)
 {
-    try
-    {
+    if (pos <= s.size())
         assert(sign(s.compare(pos, n1, str, n2)) == sign(x));
-        assert(pos <= s.size());
-    }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos > s.size());
+        try
+        {
+            s.compare(pos, n1, str, n2);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos > s.size());
+        }
     }
+#endif
 }
 
 template <class S>
Index: test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp
+++ test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // int compare(size_type pos, size_type n1, const charT *s) const;
@@ -18,6 +17,8 @@
 
 #include "min_allocator.h"
 
+#include "test_macros.h"
+
 int sign(int x)
 {
     if (x == 0)
@@ -32,15 +33,22 @@
 test(const S& s, typename S::size_type pos1, typename S::size_type n1,
      const typename S::value_type* str, int x)
 {
-    try
-    {
+    if (pos1 <= s.size())
         assert(sign(s.compare(pos1, n1, str)) == sign(x));
-        assert(pos1 <= s.size());
-    }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos1 > s.size());
+        try
+        {
+            s.compare(pos1, n1, str);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos1 > s.size());
+        }
     }
+#endif
 }
 
 template <class S>
Index: test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp
+++ test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // template <typename T>
@@ -22,6 +21,8 @@
 
 #include "min_allocator.h"
 
+#include "test_macros.h"
+
 int sign(int x)
 {
     if (x == 0)
@@ -37,34 +38,46 @@
      SV sv,      typename S::size_type pos2, typename S::size_type n2, int x)
 {
     static_assert((!std::is_same<S, SV>::value), "");
-    try
-    {
+    if (pos1 <= s.size() && pos2 <= sv.size())
         assert(sign(s.compare(pos1, n1, sv, pos2, n2)) == sign(x));
-        assert(pos1 <= s.size());
-        assert(pos2 <= sv.size());
-    }
-    catch (const std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos1 > s.size() || pos2 > sv.size());
+        try
+        {
+            s.compare(pos1, n1, sv, pos2, n2);
+            assert(false);
+        }
+        catch (const std::out_of_range&)
+        {
+            assert(pos1 > s.size() || pos2 > sv.size());
+        }
     }
+#endif
 }
 
 template <class S, class SV>
 void
 test_npos(const S& s, typename S::size_type pos1, typename S::size_type n1,
           SV sv,      typename S::size_type pos2, int x)
 {
     static_assert((!std::is_same<S, SV>::value), "");
-    try
-    {
+    if (pos1 <= s.size() && pos2 <= sv.size())
         assert(sign(s.compare(pos1, n1, sv, pos2)) == sign(x));
-        assert(pos1 <= s.size());
-        assert(pos2 <= sv.size());
-    }
-    catch (const std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos1 > s.size() || pos2 > sv.size());
+        try
+        {
+            s.compare(pos1, n1, sv, pos2);
+            assert(false);
+        }
+        catch (const std::out_of_range&)
+        {
+            assert(pos1 > s.size() || pos2 > sv.size());
+        }
     }
+#endif
 }
 
 template <class S, class SV>
Index: test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp
+++ test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // basic_string<charT,traits,Allocator>&
@@ -31,21 +30,30 @@
 {
     typename S::size_type old_size = s.size();
     S s0 = s;
-    try
+    if (pos1 <= old_size && pos2 <= str.size())
     {
         s.replace(pos1, n1, str, pos2, n2);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos1 <= old_size && pos2 <= str.size());
         assert(s == expected);
         typename S::size_type xlen = std::min(n1, old_size - pos1);
         typename S::size_type rlen = std::min(n2, str.size() - pos2);
         assert(s.size() == old_size - xlen + rlen);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos1 > old_size || pos2 > str.size());
-        assert(s == s0);
+        try
+        {
+            s.replace(pos1, n1, str, pos2, n2);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos1 > old_size || pos2 > str.size());
+            assert(s == s0);
+        }
     }
+#endif
 }
 
 template <class S>
@@ -56,21 +64,30 @@
 {
     typename S::size_type old_size = s.size();
     S s0 = s;
-    try
+    if (pos1 <= old_size && pos2 <= str.size())
     {
         s.replace(pos1, n1, str, pos2);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos1 <= old_size && pos2 <= str.size());
         assert(s == expected);
         typename S::size_type xlen = std::min(n1, old_size - pos1);
         typename S::size_type rlen = std::min(S::npos, str.size() - pos2);
         assert(s.size() == old_size - xlen + rlen);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos1 > old_size || pos2 > str.size());
-        assert(s == s0);
+        try
+        {
+            s.replace(pos1, n1, str, pos2);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos1 > old_size || pos2 > str.size());
+            assert(s == s0);
+        }
     }
+#endif
 }
 
 
Index: test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp
+++ test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // basic_string<charT,traits,Allocator>&
@@ -27,21 +26,30 @@
 {
     typename S::size_type old_size = s.size();
     S s0 = s;
-    try
+    if (pos1 <= old_size)
     {
         s.replace(pos1, n1, str);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos1 <= old_size);
         assert(s == expected);
         typename S::size_type xlen = std::min(n1, old_size - pos1);
         typename S::size_type rlen = str.size();
         assert(s.size() == old_size - xlen + rlen);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos1 > old_size);
-        assert(s == s0);
+        try
+        {
+            s.replace(pos1, n1, str);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos1 > old_size);
+            assert(s == s0);
+        }
     }
+#endif
 }
 
 template <class S>
Index: test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp
+++ test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // basic_string<charT,traits,Allocator>&
@@ -29,21 +28,30 @@
 {
     typename S::size_type old_size = s.size();
     S s0 = s;
-    try
+    if (pos <= old_size)
     {
         s.replace(pos, n1, n2, c);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos <= old_size);
         assert(s == expected);
         typename S::size_type xlen = std::min(n1, old_size - pos);
         typename S::size_type rlen = n2;
         assert(s.size() == old_size - xlen + rlen);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos > old_size);
-        assert(s == s0);
+        try
+        {
+            s.replace(pos, n1, n2, c);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos > old_size);
+            assert(s == s0);
+        }
     }
+#endif
 }
 
 template <class S>
Index: test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp
+++ test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // basic_string<charT,traits,Allocator>&
@@ -29,21 +28,30 @@
 {
     typename S::size_type old_size = s.size();
     S s0 = s;
-    try
+    if (pos <= old_size)
     {
         s.replace(pos, n1, str, n2);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos <= old_size);
         assert(s == expected);
         typename S::size_type xlen = std::min(n1, old_size - pos);
         typename S::size_type rlen = n2;
         assert(s.size() == old_size - xlen + rlen);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos > old_size);
-        assert(s == s0);
+        try
+        {
+            s.replace(pos, n1, str, n2);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos > old_size);
+            assert(s == s0);
+        }
     }
+#endif
 }
 
 template <class S>
Index: test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp
+++ test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // basic_string<charT,traits,Allocator>&
@@ -28,21 +27,30 @@
 {
     typename S::size_type old_size = s.size();
     S s0 = s;
-    try
+    if (pos <= old_size)
     {
         s.replace(pos, n1, str);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos <= old_size);
         assert(s == expected);
         typename S::size_type xlen = std::min(n1, old_size - pos);
         typename S::size_type rlen = S::traits_type::length(str);
         assert(s.size() == old_size - xlen + rlen);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos > old_size);
-        assert(s == s0);
+        try
+        {
+            s.replace(pos, n1, str);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos > old_size);
+            assert(s == s0);
+        }
     }
+#endif
 }
 
 template <class S>
Index: test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp
+++ test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // template <class T>
@@ -33,21 +32,30 @@
     static_assert((!std::is_same<S, SV>::value), "");
     typename S::size_type old_size = s.size();
     S s0 = s;
-    try
+    if (pos1 <= old_size && pos2 <= sv.size())
     {
         s.replace(pos1, n1, sv, pos2, n2);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos1 <= old_size && pos2 <= sv.size());
         assert(s == expected);
         typename S::size_type xlen = std::min(n1, old_size - pos1);
         typename S::size_type rlen = std::min(n2, sv.size() - pos2);
         assert(s.size() == old_size - xlen + rlen);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos1 > old_size || pos2 > sv.size());
-        assert(s == s0);
+        try
+        {
+            s.replace(pos1, n1, sv, pos2, n2);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos1 > old_size || pos2 > sv.size());
+            assert(s == s0);
+        }
     }
+#endif
 }
 
 template <class S, class SV>
@@ -59,21 +67,30 @@
     static_assert((!std::is_same<S, SV>::value), "");
     typename S::size_type old_size = s.size();
     S s0 = s;
-    try
+    if (pos1 <= old_size && pos2 <= sv.size())
     {
         s.replace(pos1, n1, sv, pos2);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos1 <= old_size && pos2 <= sv.size());
         assert(s == expected);
         typename S::size_type xlen = std::min(n1, old_size - pos1);
         typename S::size_type rlen = std::min(S::npos, sv.size() - pos2);
         assert(s.size() == old_size - xlen + rlen);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos1 > old_size || pos2 > sv.size());
-        assert(s == s0);
+        try
+        {
+            s.replace(pos1, n1, sv, pos2);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos1 > old_size || pos2 > sv.size());
+            assert(s == s0);
+        }
     }
+#endif
 }
 
 
Index: test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp
+++ test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // basic_string<charT,traits,Allocator>&
@@ -29,38 +28,56 @@
 {
     typename S::size_type old_size = s.size();
     S s0 = s;
-    try
+    if (pos1 <= old_size && pos2 <= str.size())
     {
         s.insert(pos1, str, pos2, n);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos1 <= old_size && pos2 <= str.size());
         assert(s == expected);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos1 > old_size || pos2 > str.size());
-        assert(s == s0);
+        try
+        {
+            s.insert(pos1, str, pos2, n);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos1 > old_size || pos2 > str.size());
+            assert(s == s0);
+        }
     }
+#endif
 }
 
 template <class S>
 void
 test_npos(S s, typename S::size_type pos1, S str, typename S::size_type pos2, S expected)
 {
     typename S::size_type old_size = s.size();
     S s0 = s;
-    try
+    if (pos1 <= old_size && pos2 <= str.size())
     {
         s.insert(pos1, str, pos2);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos1 <= old_size && pos2 <= str.size());
         assert(s == expected);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos1 > old_size || pos2 > str.size());
-        assert(s == s0);
+        try
+        {
+            s.insert(pos1, str, pos2);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos1 > old_size || pos2 > str.size());
+            assert(s == s0);
+        }
     }
+#endif
 }
 
 
Index: test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp
+++ test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // basic_string<charT,traits,Allocator>&
@@ -26,18 +25,27 @@
 {
     typename S::size_type old_size = s.size();
     S s0 = s;
-    try
+    if (pos <= old_size)
     {
         s.insert(pos, str);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos <= old_size);
         assert(s == expected);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos > old_size);
-        assert(s == s0);
+        try
+        {
+            s.insert(pos, str);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos > old_size);
+            assert(s == s0);
+        }
     }
+#endif
 }
 
 int main()
Index: test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp
+++ test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // basic_string<charT,traits,Allocator>&
@@ -27,18 +26,27 @@
 {
     typename S::size_type old_size = s.size();
     S s0 = s;
-    try
+    if (pos <= old_size)
     {
         s.insert(pos, n, str);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos <= old_size);
         assert(s == expected);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos > old_size);
-        assert(s == s0);
+        try
+        {
+            s.insert(pos, n, str);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos > old_size);
+            assert(s == s0);
+        }
     }
+#endif
 }
 
 int main()
Index: test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp
+++ test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // basic_string<charT,traits,Allocator>&
@@ -27,18 +26,27 @@
 {
     typename S::size_type old_size = s.size();
     S s0 = s;
-    try
+    if (pos <= old_size)
     {
         s.insert(pos, str, n);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos <= old_size);
         assert(s == expected);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos > old_size);
-        assert(s == s0);
+        try
+        {
+            s.insert(pos, str, n);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos > old_size);
+            assert(s == s0);
+        }
     }
+#endif
 }
 
 int main()
Index: test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp
+++ test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // basic_string<charT,traits,Allocator>&
@@ -26,18 +25,27 @@
 {
     typename S::size_type old_size = s.size();
     S s0 = s;
-    try
+    if (pos <= old_size)
     {
         s.insert(pos, str);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos <= old_size);
         assert(s == expected);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos > old_size);
-        assert(s == s0);
+        try
+        {
+            s.insert(pos, str);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos > old_size);
+            assert(s == s0);
+        }
     }
+#endif
 }
 
 int main()
Index: test/std/strings/basic.string/string.modifiers/string_insert/size_T_size_size.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.modifiers/string_insert/size_T_size_size.pass.cpp
+++ test/std/strings/basic.string/string.modifiers/string_insert/size_T_size_size.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // template <class T>
@@ -30,18 +29,27 @@
     static_assert((!std::is_same<S, SV>::value), "");
     typename S::size_type old_size = s.size();
     S s0 = s;
-    try
+    if (pos1 <= old_size && pos2 <= sv.size())
     {
         s.insert(pos1, sv, pos2, n);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos1 <= old_size && pos2 <= sv.size());
         assert(s == expected);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos1 > old_size || pos2 > sv.size());
-        assert(s == s0);
+        try
+        {
+            s.insert(pos1, sv, pos2, n);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos1 > old_size || pos2 > sv.size());
+            assert(s == s0);
+        }
     }
+#endif
 }
 
 template <class S, class SV>
@@ -51,18 +59,27 @@
     static_assert((!std::is_same<S, SV>::value), "");
     typename S::size_type old_size = s.size();
     S s0 = s;
-    try
+    if (pos1 <= old_size && pos2 <= sv.size())
     {
         s.insert(pos1, sv, pos2);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos1 <= old_size && pos2 <= sv.size());
         assert(s == expected);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos1 > old_size || pos2 > sv.size());
-        assert(s == s0);
+        try
+        {
+            s.insert(pos1, sv, pos2);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos1 > old_size || pos2 > sv.size());
+            assert(s == s0);
+        }
     }
+#endif
 }
 
 
Index: test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp
+++ test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // basic_string<charT,traits,Allocator>&
@@ -26,38 +25,56 @@
 {
     typename S::size_type old_size = s.size();
     S s0 = s;
-    try
+    if (pos <= old_size)
     {
         s.erase(pos, n);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos <= old_size);
         assert(s == expected);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos > old_size);
-        assert(s == s0);
+        try
+        {
+            s.erase(pos, n);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos > old_size);
+            assert(s == s0);
+        }
     }
+#endif
 }
 
 template <class S>
 void
 test(S s, typename S::size_type pos, S expected)
 {
     typename S::size_type old_size = s.size();
     S s0 = s;
-    try
+    if (pos <= old_size)
     {
         s.erase(pos);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos <= old_size);
         assert(s == expected);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos > old_size);
-        assert(s == s0);
+        try
+        {
+            s.erase(pos);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos > old_size);
+            assert(s == s0);
+        }
     }
+#endif
 }
 
 template <class S>
Index: test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp
+++ test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // size_type copy(charT* s, size_type n, size_type pos = 0) const;
@@ -25,20 +24,29 @@
 test(S str, typename S::value_type* s, typename S::size_type n,
      typename S::size_type pos)
 {
-    try
+    const S& cs = str;
+    if (pos <= cs.size())
     {
-        const S& cs = str;
         typename S::size_type r = cs.copy(s, n, pos);
-        assert(pos <= cs.size());
         typename S::size_type rlen = std::min(n, cs.size() - pos);
         assert(r == rlen);
         for (r = 0; r < rlen; ++r)
             assert(S::traits_type::eq(cs[pos+r], s[r]));
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos > str.size());
+        try
+        {
+            typename S::size_type r = cs.copy(s, n, pos);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos > str.size());
+        }
     }
+#endif
 }
 
 int main()
Index: test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp
+++ test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // basic_string<charT,traits,Allocator>&
@@ -25,34 +24,52 @@
 void
 test(S s, S str, typename S::size_type pos, typename S::size_type n, S expected)
 {
-    try
+    if (pos <= str.size())
     {
         s.assign(str, pos, n);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos <= str.size());
         assert(s == expected);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos > str.size());
+        try
+        {
+            s.assign(str, pos, n);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos > str.size());
+        }
     }
+#endif
 }
 
 template <class S>
 void
 test_npos(S s, S str, typename S::size_type pos, S expected)
 {
-    try
+    if (pos <= str.size())
     {
         s.assign(str, pos);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos <= str.size());
         assert(s == expected);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos > str.size());
+        try
+        {
+            s.assign(str, pos);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos > str.size());
+        }
     }
+#endif
 }
 
 int main()
Index: test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp
+++ test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // template <class T>
@@ -24,34 +23,52 @@
 void
 test(S s, SV sv, typename S::size_type pos, typename S::size_type n, S expected)
 {
-    try
+    if (pos <= sv.size())
     {
         s.assign(sv, pos, n);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos <= sv.size());
         assert(s == expected);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos > sv.size());
+        try
+        {
+            s.assign(sv, pos, n);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos > sv.size());
+        }
     }
+#endif
 }
 
 template <class S, class SV>
 void
 test_npos(S s, SV sv, typename S::size_type pos, S expected)
 {
-    try
+    if (pos <= sv.size())
     {
         s.assign(sv, pos);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos <= sv.size());
         assert(s == expected);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos > sv.size());
+        try
+        {
+            s.assign(sv, pos);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos > sv.size());
+        }
     }
+#endif
 }
 
 int main()
Index: test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp
+++ test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // basic_string<charT,traits,Allocator>&
@@ -25,34 +24,52 @@
 void
 test(S s, S str, typename S::size_type pos, typename S::size_type n, S expected)
 {
-    try
+    if (pos <= str.size())
     {
         s.append(str, pos, n);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos <= str.size());
         assert(s == expected);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos > str.size());
+        try
+        {
+            s.append(str, pos, n);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos > str.size());
+        }
     }
+#endif
 }
 
 template <class S>
 void
 test_npos(S s, S str, typename S::size_type pos, S expected)
 {
-    try
+    if (pos <= str.size())
     {
         s.append(str, pos);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos <= str.size());
         assert(s == expected);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos > str.size());
+        try
+        {
+            s.append(str, pos);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos > str.size());
+        }
     }
+#endif
 }
 
 int main()
Index: test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp
+++ test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // template <class T>
@@ -25,34 +24,52 @@
 void
 test(S s, SV sv, typename S::size_type pos, typename S::size_type n, S expected)
 {
-    try
+    if (pos <= sv.size())
     {
         s.append(sv, pos, n);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos <= sv.size());
         assert(s == expected);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos > sv.size());
+        try
+        {
+            s.append(sv, pos, n);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos > sv.size());
+        }
     }
+#endif
 }
 
 template <class S, class SV>
 void
 test_npos(S s, SV sv, typename S::size_type pos, S expected)
 {
-    try
+    if (pos <= sv.size())
     {
         s.append(sv, pos);
         LIBCPP_ASSERT(s.__invariants());
-        assert(pos <= sv.size());
         assert(s == expected);
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos > sv.size());
+        try
+        {
+            s.append(sv, pos);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos > sv.size());
+        }
     }
+#endif
 }
 
 int main()
Index: test/std/strings/basic.string/string.cons/substr.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.cons/substr.pass.cpp
+++ test/std/strings/basic.string/string.cons/substr.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // basic_string(const basic_string<charT,traits,Allocator>& str,
@@ -35,70 +34,100 @@
 {
     typedef typename S::traits_type T;
     typedef typename S::allocator_type A;
-    try
+
+    if (pos <= str.size())
     {
         S s2(str, pos);
         LIBCPP_ASSERT(s2.__invariants());
-        assert(pos <= str.size());
         unsigned rlen = str.size() - pos;
         assert(s2.size() == rlen);
         assert(T::compare(s2.data(), str.data() + pos, rlen) == 0);
         assert(s2.get_allocator() == A());
         assert(s2.capacity() >= s2.size());
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos > str.size());
+        try
+        {
+            S s2(str, pos);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos > str.size());
+        }
     }
+#endif
 }
 
 template <class S>
 void
 test(S str, unsigned pos, unsigned n)
 {
     typedef typename S::traits_type T;
     typedef typename S::allocator_type A;
-    try
+    if (pos <= str.size())
     {
         S s2(str, pos, n);
         LIBCPP_ASSERT(s2.__invariants());
-        assert(pos <= str.size());
         unsigned rlen = std::min<unsigned>(str.size() - pos, n);
         assert(s2.size() == rlen);
         assert(T::compare(s2.data(), str.data() + pos, rlen) == 0);
         assert(s2.get_allocator() == A());
         assert(s2.capacity() >= s2.size());
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos > str.size());
+        try
+        {
+            S s2(str, pos, n);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos > str.size());
+        }
     }
+#endif
 }
 
 template <class S>
 void
 test(S str, unsigned pos, unsigned n, const typename S::allocator_type& a)
 {
     typedef typename S::traits_type T;
     typedef typename S::allocator_type A;
-    try
+
+    if (pos <= str.size())
     {
         S s2(str, pos, n, a);
         LIBCPP_ASSERT(s2.__invariants());
-        assert(pos <= str.size());
         unsigned rlen = std::min<unsigned>(str.size() - pos, n);
         assert(s2.size() == rlen);
         assert(T::compare(s2.data(), str.data() + pos, rlen) == 0);
         assert(s2.get_allocator() == a);
         assert(s2.capacity() >= s2.size());
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos > str.size());
+        try
+        {
+            S s2(str, pos, n, a);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos > str.size());
+        }
     }
+#endif
 }
 
 #if TEST_STD_VER >= 11
+#ifndef TEST_HAS_NO_EXCEPTIONS
 void test2583()
 {   // LWG #2583
     typedef std::basic_string<char, std::char_traits<char>, test_allocator<char> > StringA;
@@ -111,6 +140,7 @@
     assert(false);
 }
 #endif
+#endif
 
 int main()
 {
@@ -192,6 +222,8 @@
     test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 100, A());
     }
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
     test2583();
 #endif
+#endif
 }
Index: test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp
+++ test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // void resize(size_type n, charT c);
@@ -23,17 +22,26 @@
 void
 test(S s, typename S::size_type n, typename S::value_type c, S expected)
 {
-    try
+    if (n <= s.max_size())
     {
         s.resize(n, c);
         LIBCPP_ASSERT(s.__invariants());
-        assert(n <= s.max_size());
         assert(s == expected);
     }
-    catch (std::length_error&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(n > s.max_size());
+        try
+        {
+            s.resize(n, c);
+            assert(false);
+        }
+        catch (std::length_error&)
+        {
+            assert(n > s.max_size());
+        }
     }
+#endif
 }
 
 int main()
Index: test/std/strings/basic.string/string.capacity/resize_size.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.capacity/resize_size.pass.cpp
+++ test/std/strings/basic.string/string.capacity/resize_size.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // void resize(size_type n);
@@ -23,17 +22,26 @@
 void
 test(S s, typename S::size_type n, S expected)
 {
-    try
+    if (n <= s.max_size())
     {
         s.resize(n);
         LIBCPP_ASSERT(s.__invariants());
-        assert(n <= s.max_size());
         assert(s == expected);
     }
-    catch (std::length_error&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(n > s.max_size());
+        try
+        {
+            s.resize(n);
+            assert(false);
+        }
+        catch (std::length_error&)
+        {
+            assert(n > s.max_size());
+        }
     }
+#endif
 }
 
 int main()
Index: test/std/strings/basic.string/string.capacity/reserve.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.capacity/reserve.pass.cpp
+++ test/std/strings/basic.string/string.capacity/reserve.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // void reserve(size_type res_arg=0);
@@ -38,18 +37,27 @@
 {
     typename S::size_type old_cap = s.capacity();
     S s0 = s;
-    try
+    if (res_arg <= s.max_size())
     {
         s.reserve(res_arg);
-        assert(res_arg <= s.max_size());
         assert(s == s0);
         assert(s.capacity() >= res_arg);
         assert(s.capacity() >= s.size());
     }
-    catch (std::length_error&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(res_arg > s.max_size());
+        try
+        {
+            s.reserve(res_arg);
+            assert(false);
+        }
+        catch (std::length_error&)
+        {
+            assert(res_arg > s.max_size());
+        }
     }
+#endif
 }
 
 int main()
Index: test/std/strings/basic.string/string.access/at.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.access/at.pass.cpp
+++ test/std/strings/basic.string/string.access/at.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <string>
 
 // const_reference at(size_type pos) const;
@@ -19,21 +18,41 @@
 
 #include "min_allocator.h"
 
+#include "test_macros.h"
+
 template <class S>
 void
 test(S s, typename S::size_type pos)
 {
-    try
+    const S& cs = s;
+    if (pos < s.size())
     {
-        const S& cs = s;
         assert(s.at(pos) == s[pos]);
         assert(cs.at(pos) == cs[pos]);
-        assert(pos < cs.size());
     }
-    catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    else
     {
-        assert(pos >= s.size());
+        try
+        {
+            s.at(pos);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos >= s.size());
+        }
+        try
+        {
+            cs.at(pos);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+            assert(pos >= s.size());
+        }
     }
+#endif
 }
 
 int main()
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to