diff options
Diffstat (limited to 'test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp')
| -rw-r--r-- | test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp | 21 | 
1 files changed, 15 insertions, 6 deletions
diff --git a/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp index b66877652837f..664d2049be997 100644 --- a/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp @@ -7,7 +7,6 @@  //  //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions  // <string>  // size_type copy(charT* s, size_type n, size_type pos = 0) const; @@ -25,20 +24,30 @@ void  test(S str, typename S::value_type* s, typename S::size_type n,       typename S::size_type pos)  { -    try +    const S& cs = str; +    if (pos <= cs.size())      { -        const S& cs = str;          typename S::size_type r = cs.copy(s, n, pos); -        assert(pos <= cs.size());          typename S::size_type rlen = std::min(n, cs.size() - pos);          assert(r == rlen);          for (r = 0; r < rlen; ++r)              assert(S::traits_type::eq(cs[pos+r], s[r]));      } -    catch (std::out_of_range&) +#ifndef TEST_HAS_NO_EXCEPTIONS +    else      { -        assert(pos > str.size()); +        try +        { +            typename S::size_type r = cs.copy(s, n, pos); +            ((void)r); // Prevent unused warning +            assert(false); +        } +        catch (std::out_of_range&) +        { +            assert(pos > str.size()); +        }      } +#endif  }  int main()  | 
