Index: libcxx/trunk/test/std/strings/basic.string/string.access/at.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.access/at.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.access/at.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // const_reference at(size_type pos) const; @@ -19,21 +18,41 @@ #include "min_allocator.h" +#include "test_macros.h" + template 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() Index: libcxx/trunk/test/std/strings/basic.string/string.capacity/reserve.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.capacity/reserve.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.capacity/reserve.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // 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: libcxx/trunk/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // 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: libcxx/trunk/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // 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: libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // basic_string(const basic_string& str, @@ -35,21 +34,31 @@ { 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 @@ -58,21 +67,30 @@ { 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(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 @@ -81,24 +99,35 @@ { 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(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, test_allocator > 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: libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // template @@ -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 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: libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // basic_string& @@ -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 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: libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // template @@ -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 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: libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // basic_string& @@ -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 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: libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // 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: libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // basic_string& @@ -24,40 +23,58 @@ void test(S s, typename S::size_type pos, typename S::size_type n, S expected) { - typename S::size_type old_size = s.size(); + const 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 void test(S s, typename S::size_type pos, S expected) { - typename S::size_type old_size = s.size(); + const 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 Index: libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_T_size_size.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_T_size_size.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_T_size_size.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // template @@ -28,20 +27,29 @@ typename S::size_type n, S expected) { static_assert((!std::is_same::value), ""); - typename S::size_type old_size = s.size(); + const 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 @@ -49,20 +57,29 @@ test_npos(S s, typename S::size_type pos1, SV sv, typename S::size_type pos2, S expected) { static_assert((!std::is_same::value), ""); - typename S::size_type old_size = s.size(); + const 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: libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // basic_string& @@ -24,20 +23,29 @@ void test(S s, typename S::size_type pos, const typename S::value_type* str, S expected) { - typename S::size_type old_size = s.size(); + const 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: libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // basic_string& @@ -25,20 +24,29 @@ test(S s, typename S::size_type pos, const typename S::value_type* str, typename S::size_type n, S expected) { - typename S::size_type old_size = s.size(); + const 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: libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // basic_string& @@ -25,20 +24,29 @@ test(S s, typename S::size_type pos, typename S::size_type n, typename S::value_type str, S expected) { - typename S::size_type old_size = s.size(); + const 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: libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // basic_string& @@ -24,20 +23,29 @@ void test(S s, typename S::size_type pos, S str, S expected) { - typename S::size_type old_size = s.size(); + const 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: libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // basic_string& @@ -27,40 +26,58 @@ test(S s, typename S::size_type pos1, S str, typename S::size_type pos2, typename S::size_type n, S expected) { - typename S::size_type old_size = s.size(); + const 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 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(); + const 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: libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // template @@ -31,23 +30,32 @@ S expected) { static_assert((!std::is_same::value), ""); - typename S::size_type old_size = s.size(); + const 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 @@ -57,23 +65,32 @@ S expected) { static_assert((!std::is_same::value), ""); - typename S::size_type old_size = s.size(); + const 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: libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // basic_string& @@ -26,23 +25,32 @@ test(S s, typename S::size_type pos, typename S::size_type n1, const typename S::value_type* str, S expected) { - typename S::size_type old_size = s.size(); + const 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 Index: libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // basic_string& @@ -27,23 +26,32 @@ const typename S::value_type* str, typename S::size_type n2, S expected) { - typename S::size_type old_size = s.size(); + const 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 Index: libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // basic_string& @@ -27,23 +26,32 @@ typename S::size_type n2, typename S::value_type c, S expected) { - typename S::size_type old_size = s.size(); + const 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 Index: libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // basic_string& @@ -25,23 +24,32 @@ void test(S s, typename S::size_type pos1, typename S::size_type n1, S str, S expected) { - typename S::size_type old_size = s.size(); + const 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 Index: libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // basic_string& @@ -29,23 +28,32 @@ S str, typename S::size_type pos2, typename S::size_type n2, S expected) { - typename S::size_type old_size = s.size(); + const 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 @@ -54,23 +62,32 @@ S str, typename S::size_type pos2, S expected) { - typename S::size_type old_size = s.size(); + const 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: libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // template @@ -22,6 +21,8 @@ #include "min_allocator.h" +#include "test_macros.h" + int sign(int x) { if (x == 0) @@ -37,16 +38,22 @@ SV sv, typename S::size_type pos2, typename S::size_type n2, int x) { static_assert((!std::is_same::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 @@ -55,16 +62,22 @@ SV sv, typename S::size_type pos2, int x) { static_assert((!std::is_same::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 Index: libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // 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 Index: libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // 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 Index: libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // 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 Index: libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp =================================================================== --- libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp +++ libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // 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,16 +35,22 @@ 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 @@ -51,16 +58,22 @@ 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