summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/strings/basic.string/string.capacity
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std/strings/basic.string/string.capacity')
-rw-r--r--libcxx/test/std/strings/basic.string/string.capacity/reserve.pass.cpp18
-rw-r--r--libcxx/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp18
-rw-r--r--libcxx/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp18
3 files changed, 39 insertions, 15 deletions
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()
OpenPOWER on IntegriCloud