From 53a420fba21cf1644972b34dcd811a43cdb8368d Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Mon, 2 Jan 2017 19:18:58 +0000 Subject: Vendor import of libc++ trunk r290819: https://llvm.org/svn/llvm-project/libcxx/trunk@290819 --- .../string.ops/string_substr/substr.pass.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp') diff --git a/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp b/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp index 145e8dde58bf5..f94739eb44138 100644 --- a/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp +++ b/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // basic_string substr(size_type pos = 0, size_type n = npos) const; @@ -24,7 +23,7 @@ template 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() -- cgit v1.2.3