diff options
28 files changed, 598 insertions, 248 deletions
diff --git a/libcxx/test/std/strings/basic.string/string.access/at.pass.cpp b/libcxx/test/std/strings/basic.string/string.access/at.pass.cpp index 8dc0c57cb7b..891648930e3 100644 --- a/libcxx/test/std/strings/basic.string/string.access/at.pass.cpp +++ b/libcxx/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() diff --git a/libcxx/test/std/strings/basic.string/string.capacity/reserve.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/reserve.pass.cpp index b2c254d1fb2..ad29f9cab5f 100644 --- a/libcxx/test/std/strings/basic.string/string.capacity/reserve.pass.cpp +++ b/libcxx/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 @@ test(S s, typename S::size_type res_arg) { 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() diff --git a/libcxx/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp index 55894159957..78200d50cb3 100644 --- a/libcxx/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp +++ b/libcxx/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 @@ template <class S> 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() diff --git a/libcxx/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp index 79f972b2fee..288eb325252 100644 --- a/libcxx/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp +++ b/libcxx/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 @@ template <class S> 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() diff --git a/libcxx/test/std/strings/basic.string/string.cons/substr.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/substr.pass.cpp index a10239bb341..381ed8b90b8 100644 --- a/libcxx/test/std/strings/basic.string/string.cons/substr.pass.cpp +++ b/libcxx/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,21 +34,31 @@ test(S str, unsigned pos) { 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> @@ -58,21 +67,30 @@ 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> @@ -81,24 +99,35 @@ 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 @@ void test2583() assert(false); } #endif +#endif int main() { @@ -192,6 +222,8 @@ int main() test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 100, A()); } +#ifndef TEST_HAS_NO_EXCEPTIONS test2583(); #endif +#endif } diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp index 82912448077..fcd18b7f05b 100644 --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp +++ b/libcxx/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 @@ template <class S, class SV> 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() diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp index 9e8158c3e43..588c15ab8d6 100644 --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp +++ b/libcxx/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 @@ template <class S> 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() diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp index 793bf6e399b..bf51d816e86 100644 --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp +++ b/libcxx/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 @@ template <class S, class SV> 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() diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp index d9d3cb422ae..2ad37f311de 100644 --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp +++ b/libcxx/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 @@ template <class S> 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() diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp index b6687765283..d8c50b61907 100644 --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp +++ b/libcxx/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 @@ void 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() diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp index 5db97ec2cf5..eb6be202a35 100644 --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp +++ b/libcxx/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>& @@ -24,40 +23,58 @@ template <class S> 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 <class S> 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 <class S> diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_T_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_T_size_size.pass.cpp index 6c49ea447f8..9a25bc9c729 100644 --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_T_size_size.pass.cpp +++ b/libcxx/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> @@ -28,20 +27,29 @@ test(S s, typename S::size_type pos1, SV sv, typename S::size_type pos2, typename S::size_type n, S expected) { static_assert((!std::is_same<S, SV>::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 <class S, class SV> @@ -49,20 +57,29 @@ void test_npos(S s, typename S::size_type pos1, SV sv, typename S::size_type pos2, S expected) { static_assert((!std::is_same<S, SV>::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 } diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp index 3b1c2cbd727..e734ffafa84 100644 --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp +++ b/libcxx/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>& @@ -24,20 +23,29 @@ template <class S> 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() diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp index 554b93cdce1..b5998437425 100644 --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp +++ b/libcxx/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>& @@ -25,20 +24,29 @@ void 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() diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp index 04ea1d37694..a769604c6ff 100644 --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp +++ b/libcxx/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>& @@ -25,20 +24,29 @@ void 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() diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp index 1945871b99a..e7c5ecdc9c1 100644 --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp +++ b/libcxx/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>& @@ -24,20 +23,29 @@ template <class S> 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() diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp index 32485db478d..67ba7ec108f 100644 --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp +++ b/libcxx/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>& @@ -27,40 +26,58 @@ void 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 <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(); + 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 } diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp index 1ebaa3b36f0..542da0d08cb 100644 --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp +++ b/libcxx/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> @@ -31,23 +30,32 @@ test(S s, typename S::size_type pos1, typename S::size_type n1, S expected) { static_assert((!std::is_same<S, SV>::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 <class S, class SV> @@ -57,23 +65,32 @@ test_npos(S s, typename S::size_type pos1, typename S::size_type n1, S expected) { static_assert((!std::is_same<S, SV>::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 } diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp index 3beb074c0fd..d09c9c2efd6 100644 --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp +++ b/libcxx/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>& @@ -26,23 +25,32 @@ void 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 <class S> diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp index d961e9e8f76..5c751285cb0 100644 --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp +++ b/libcxx/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>& @@ -27,23 +26,32 @@ test(S s, typename S::size_type pos, typename S::size_type n1, 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 <class S> diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp index d4696fba8a8..75745dab61f 100644 --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp +++ b/libcxx/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>& @@ -27,23 +26,32 @@ test(S s, typename S::size_type pos, typename S::size_type n1, 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 <class S> diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp index 1be45d8a662..612e1e200c9 100644 --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp +++ b/libcxx/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>& @@ -25,23 +24,32 @@ template <class S> 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 <class S> diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp index 3f4bf450d85..b49b6f987b0 100644 --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp +++ b/libcxx/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>& @@ -29,23 +28,32 @@ test(S s, typename S::size_type pos1, typename S::size_type n1, 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 <class S> @@ -54,23 +62,32 @@ test_npos(S s, typename S::size_type pos1, typename S::size_type n1, 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 } diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp index 2cdc348b6d3..bc2bf656db0 100644 --- a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp +++ b/libcxx/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,16 +38,22 @@ test(const S& s, typename S::size_type pos1, typename S::size_type n1, 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> @@ -55,16 +62,22 @@ 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> diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp index 094c227030b..13f6c5a1cd7 100644 --- a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp +++ b/libcxx/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 @@ void 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> diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp index 22aae785c19..fc811c84671 100644 --- a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp +++ b/libcxx/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 @@ void 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> diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp index 90b4230f64d..b3d7da29fb1 100644 --- a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp +++ b/libcxx/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 @@ void 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> diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp index 10f9d849c2b..42bba9d5eb2 100644 --- a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp +++ b/libcxx/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,16 +35,22 @@ void 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> @@ -51,16 +58,22 @@ 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> |