diff options
author | Roger Ferrer Ibanez <roger.ferreribanez@arm.com> | 2016-11-29 16:40:19 +0000 |
---|---|---|
committer | Roger Ferrer Ibanez <roger.ferreribanez@arm.com> | 2016-11-29 16:40:19 +0000 |
commit | 9d03c03858e99525969edade670a8f8ccb706d64 (patch) | |
tree | 8c8f87c41bbd438cc51384d2387a0125ca3d20d4 | |
parent | f2e50651f653adaaa72cfe6c3c9a7c6fc87124cb (diff) | |
download | bcm5719-llvm-9d03c03858e99525969edade670a8f8ccb706d64.tar.gz bcm5719-llvm-9d03c03858e99525969edade670a8f8ccb706d64.zip |
Protect std::string tests under libcpp-no-exceptions
Skip tests that expect an exception be thrown and/or disable
unreachable catch handlers.
Differential Revision: https://reviews.llvm.org/D26612
llvm-svn: 288158
-rw-r--r-- | libcxx/test/std/strings/basic.string/string.capacity/capacity.pass.cpp | 7 | ||||
-rw-r--r-- | libcxx/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp | 17 |
2 files changed, 19 insertions, 5 deletions
diff --git a/libcxx/test/std/strings/basic.string/string.capacity/capacity.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/capacity.pass.cpp index 4b09c096792..79fbd2e9632 100644 --- a/libcxx/test/std/strings/basic.string/string.capacity/capacity.pass.cpp +++ b/libcxx/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/libcxx/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp index 145e8dde58b..f94739eb441 100644 --- a/libcxx/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // <string> // basic_string substr(size_type pos = 0, size_type n = npos) const; @@ -24,7 +23,7 @@ template <class S> void test(const S& s, typename S::size_type pos, typename S::size_type n) { - try + if (pos <= s.size()) { S str = s.substr(pos, n); LIBCPP_ASSERT(str.__invariants()); @@ -33,10 +32,20 @@ test(const S& s, typename S::size_type pos, typename S::size_type n) assert(str.size() == rlen); assert(S::traits_type::compare(s.data()+pos, str.data(), rlen) == 0); } - catch (std::out_of_range&) +#ifndef TEST_HAS_NO_EXCEPTIONS + else { - assert(pos > s.size()); + try + { + S str = s.substr(pos, n); + assert(false); + } + catch (std::out_of_range&) + { + assert(pos > s.size()); + } } +#endif } int main() |