mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-23 01:18:52 +08:00
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 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@288158 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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()
|
||||
|
Reference in New Issue
Block a user