mirror of
https://github.com/darlinghq/darling-libcxx.git
synced 2024-12-04 01:54:02 +00:00
Fix some string_view tests that were failing when exceptions were disabled. Also comment out a _LIBCPP_ASSERT that gcc4.9 was complaining about. Will revisit that later.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276241 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1e00d6db31
commit
15362334f6
@ -206,9 +206,9 @@ public:
|
||||
basic_string_view(const _CharT* __s, size_type __len)
|
||||
: __data(__s), __size(__len)
|
||||
{
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
_LIBCPP_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): received nullptr");
|
||||
#endif
|
||||
// #if _LIBCPP_STD_VER > 11
|
||||
// _LIBCPP_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): received nullptr");
|
||||
// #endif
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
|
@ -22,6 +22,10 @@ int sign ( int x ) { return x > 0 ? 1 : ( x < 0 ? -1 : 0 ); }
|
||||
template<typename CharT>
|
||||
void test1 ( std::basic_string_view<CharT> sv1,
|
||||
size_t pos1, size_t n1, const CharT *s, int expected ) {
|
||||
#ifdef TEST_HAS_NO_EXCEPTIONS
|
||||
if (pos1 <= sv1.size())
|
||||
assert(sign(sv1.compare(pos1, n1, s)) == sign(expected));
|
||||
#else
|
||||
try {
|
||||
assert(sign(sv1.compare(pos1, n1, s)) == sign(expected));
|
||||
assert(pos1 <= sv1.size());
|
||||
@ -29,6 +33,7 @@ void test1 ( std::basic_string_view<CharT> sv1,
|
||||
catch (const std::out_of_range&) {
|
||||
assert(pos1 > sv1.size());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename CharT>
|
||||
|
@ -22,6 +22,10 @@ int sign ( int x ) { return x > 0 ? 1 : ( x < 0 ? -1 : 0 ); }
|
||||
template<typename CharT>
|
||||
void test1 ( std::basic_string_view<CharT> sv1, size_t pos1, size_t n1,
|
||||
std::basic_string_view<CharT> sv2, int expected ) {
|
||||
#ifdef TEST_HAS_NO_EXCEPTIONS
|
||||
if (pos1 <= sv1.size())
|
||||
assert(sign( sv1.compare(pos1, n1, sv2)) == sign(expected));
|
||||
#else
|
||||
try {
|
||||
assert(sign( sv1.compare(pos1, n1, sv2)) == sign(expected));
|
||||
assert(pos1 <= sv1.size());
|
||||
@ -29,6 +33,7 @@ void test1 ( std::basic_string_view<CharT> sv1, size_t pos1, size_t n1,
|
||||
catch (const std::out_of_range&) {
|
||||
assert(pos1 > sv1.size());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,6 +23,10 @@ int sign ( int x ) { return x > 0 ? 1 : ( x < 0 ? -1 : 0 ); }
|
||||
template<typename CharT>
|
||||
void test1 ( std::basic_string_view<CharT> sv1, size_t pos1, size_t n1,
|
||||
const CharT *s2, size_t n2, int expected ) {
|
||||
#ifdef TEST_HAS_NO_EXCEPTIONS
|
||||
if (pos1 <= sv1.size())
|
||||
assert(sign(sv1.compare(pos1, n1, s2, n2)) == sign(expected));
|
||||
#else
|
||||
try {
|
||||
assert(sign(sv1.compare(pos1, n1, s2, n2)) == sign(expected));
|
||||
assert(pos1 <= sv1.size());
|
||||
@ -30,6 +34,7 @@ void test1 ( std::basic_string_view<CharT> sv1, size_t pos1, size_t n1,
|
||||
catch (const std::out_of_range&) {
|
||||
assert(pos1 > sv1.size());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,6 +24,10 @@ template<typename CharT>
|
||||
void test1 ( std::basic_string_view<CharT> sv1, size_t pos1, size_t n1,
|
||||
std::basic_string_view<CharT> sv2, size_t pos2, size_t n2,
|
||||
int expected ) {
|
||||
#ifdef TEST_HAS_NO_EXCEPTIONS
|
||||
if (pos1 <= sv1.size() && pos2 <= sv2.size())
|
||||
assert (sign( sv1.compare(pos1, n1, sv2, pos2, n2)) == sign(expected));
|
||||
#else
|
||||
try {
|
||||
assert (sign( sv1.compare(pos1, n1, sv2, pos2, n2)) == sign(expected));
|
||||
assert(pos1 <= sv1.size() && pos2 <= sv2.size());
|
||||
@ -31,6 +35,7 @@ void test1 ( std::basic_string_view<CharT> sv1, size_t pos1, size_t n1,
|
||||
catch (const std::out_of_range&) {
|
||||
assert(pos1 > sv1.size() || pos2 > sv2.size());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,16 +22,21 @@
|
||||
|
||||
template<typename CharT>
|
||||
void test1(std::basic_string_view<CharT> sv, size_t n, size_t pos) {
|
||||
try {
|
||||
std::basic_string_view<CharT> sv1 = sv.substr(pos, n);
|
||||
#ifdef TEST_HAS_NO_EXCEPTIONS
|
||||
if (pos <= sv.size())
|
||||
assert (sign( sv1.compare(pos1, n1, sv2)) == sign(expected));
|
||||
#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]);
|
||||
}
|
||||
catch (const std::out_of_range&) {
|
||||
assert(pos > sv.size());
|
||||
}
|
||||
}
|
||||
catch (const std::out_of_range&) {
|
||||
assert(pos > sv.size());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user