forked from OSchip/llvm-project
Another fix to appease the no-exception bots.
llvm-svn: 276272
This commit is contained in:
parent
e89c62a102
commit
ef68f26b28
|
@ -22,21 +22,25 @@
|
|||
|
||||
template<typename CharT>
|
||||
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
|
||||
if (pos <= sv.size())
|
||||
assert (sign( sv1.compare(pos1, n1, sv2)) == sign(expected));
|
||||
if (pos > sv.size())
|
||||
return ; // would throw if exceptions were enabled
|
||||
sv1 = sv.substr(pos, n);
|
||||
#else
|
||||
try {
|
||||
std::basic_string_view<CharT> sv1 = sv.substr(pos, n);
|
||||
const size_t rlen = std::min(n, sv.size() - pos);
|
||||
assert (sv1.size() == rlen);
|
||||
for (size_t i = 0; i <= rlen; ++i)
|
||||
assert(sv[pos+i] == sv1[i]);
|
||||
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);
|
||||
assert (sv1.size() == rlen);
|
||||
for (size_t i = 0; i <= rlen; ++i)
|
||||
assert(sv[pos+i] == sv1[i]);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue