summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
diff options
context:
space:
mode:
authorRoger Ferrer Ibanez <roger.ferreribanez@arm.com>2016-11-24 11:15:09 +0000
committerRoger Ferrer Ibanez <roger.ferreribanez@arm.com>2016-11-24 11:15:09 +0000
commitc65daf3e4ae4b00fbd8514ac8df9ac216a4d0822 (patch)
tree1905e03f290ca5237e6b4d19b112872e0ac85b7c /libcxx/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
parent1eff73c3244867e0f4ba379a661da33b27814434 (diff)
downloadbcm5719-llvm-c65daf3e4ae4b00fbd8514ac8df9ac216a4d0822.tar.gz
bcm5719-llvm-c65daf3e4ae4b00fbd8514ac8df9ac216a4d0822.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/D26608 llvm-svn: 287865
Diffstat (limited to 'libcxx/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp')
-rw-r--r--libcxx/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp9
1 files changed, 8 insertions, 1 deletions
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..970f9e4bcd1 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,19 +23,27 @@ template <class S>
void
test(const S& s, typename S::size_type pos, typename S::size_type n)
{
+#ifndef TEST_HAS_NO_EXCEPTIONS
try
+#else
+ if (pos <= s.size())
+#endif
{
S str = s.substr(pos, n);
LIBCPP_ASSERT(str.__invariants());
+#ifndef TEST_HAS_NO_EXCEPTIONS
assert(pos <= s.size());
+#endif
typename S::size_type rlen = std::min(n, s.size() - pos);
assert(str.size() == rlen);
assert(S::traits_type::compare(s.data()+pos, str.data(), rlen) == 0);
}
+#ifndef TEST_HAS_NO_EXCEPTIONS
catch (std::out_of_range&)
{
assert(pos > s.size());
}
+#endif
}
int main()
OpenPOWER on IntegriCloud