diff options
Diffstat (limited to 'test/std/strings/basic.string/string.capacity')
6 files changed, 48 insertions, 18 deletions
diff --git a/test/std/strings/basic.string/string.capacity/capacity.pass.cpp b/test/std/strings/basic.string/string.capacity/capacity.pass.cpp index 4b09c096792c..79fbd2e96322 100644 --- a/test/std/strings/basic.string/string.capacity/capacity.pass.cpp +++ b/test/std/strings/basic.string/string.capacity/capacity.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // <string> // size_type capacity() const; @@ -18,21 +17,27 @@ #include "test_allocator.h" #include "min_allocator.h" +#include "test_macros.h" + template <class S> void test(S s) { S::allocator_type::throw_after = 0; +#ifndef TEST_HAS_NO_EXCEPTIONS try +#endif { while (s.size() < s.capacity()) s.push_back(typename S::value_type()); assert(s.size() == s.capacity()); } +#ifndef TEST_HAS_NO_EXCEPTIONS catch (...) { assert(false); } +#endif S::allocator_type::throw_after = INT_MAX; } diff --git a/test/std/strings/basic.string/string.capacity/max_size.pass.cpp b/test/std/strings/basic.string/string.capacity/max_size.pass.cpp index fca14ddca561..a8f8126f7e6b 100644 --- a/test/std/strings/basic.string/string.capacity/max_size.pass.cpp +++ b/test/std/strings/basic.string/string.capacity/max_size.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions +// UNSUPPORTED: libcpp-no-exceptions // <string> // size_type max_size() const; diff --git a/test/std/strings/basic.string/string.capacity/over_max_size.pass.cpp b/test/std/strings/basic.string/string.capacity/over_max_size.pass.cpp index e92a0e1054f6..59267f245d82 100644 --- a/test/std/strings/basic.string/string.capacity/over_max_size.pass.cpp +++ b/test/std/strings/basic.string/string.capacity/over_max_size.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions +// UNSUPPORTED: libcpp-no-exceptions // <string> // size_type max_size() const; diff --git a/test/std/strings/basic.string/string.capacity/reserve.pass.cpp b/test/std/strings/basic.string/string.capacity/reserve.pass.cpp index b2c254d1fb25..7210152ea3cb 100644 --- a/test/std/strings/basic.string/string.capacity/reserve.pass.cpp +++ b/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); @@ -37,19 +36,29 @@ void test(S s, typename S::size_type res_arg) { typename S::size_type old_cap = s.capacity(); + ((void)old_cap); // Prevent unused warning 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/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp b/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp index 558941599578..78200d50cb3e 100644 --- a/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp +++ b/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/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp b/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp index 79f972b2fee3..288eb325252b 100644 --- a/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp +++ b/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() |
