Another fix to appease the no-exception bots.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276272 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow
2016-07-21 13:18:50 +00:00
parent 15362334f6
commit f82c1cef1d

View File

@@ -22,22 +22,26 @@
template<typename CharT> template<typename CharT>
void test1(std::basic_string_view<CharT> sv, size_t n, size_t pos) { void test1(std::basic_string_view<CharT> sv, size_t n, size_t pos) {
std::basic_string_view<CharT> sv1;
#ifdef TEST_HAS_NO_EXCEPTIONS #ifdef TEST_HAS_NO_EXCEPTIONS
if (pos <= sv.size()) if (pos > sv.size())
assert (sign( sv1.compare(pos1, n1, sv2)) == sign(expected)); return ; // would throw if exceptions were enabled
sv1 = sv.substr(pos, n);
#else #else
try { try {
std::basic_string_view<CharT> sv1 = sv.substr(pos, n); sv1 = sv.substr(pos, n);
assert(pos <= sv.size());
}
catch (const std::out_of_range&) {
assert(pos > sv.size());
return ;
}
#endif
const size_t rlen = std::min(n, sv.size() - pos); const size_t rlen = std::min(n, sv.size() - pos);
assert (sv1.size() == rlen); assert (sv1.size() == rlen);
for (size_t i = 0; i <= rlen; ++i) for (size_t i = 0; i <= rlen; ++i)
assert(sv[pos+i] == sv1[i]); assert(sv[pos+i] == sv1[i]);
} }
catch (const std::out_of_range&) {
assert(pos > sv.size());
}
#endif
}
template<typename CharT> template<typename CharT>