Guard libc++ specific c.__invariants() tests in LIBCPP_ASSERT macros
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@267947 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -11,14 +11,11 @@
|
||||
|
||||
// iterator insert(const_iterator p, charT c);
|
||||
|
||||
#if _LIBCPP_DEBUG >= 1
|
||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
@@ -28,7 +25,7 @@ test(S& s, typename S::const_iterator p, typename S::value_type c, S expected)
|
||||
bool sufficient_cap = s.size() < s.capacity();
|
||||
typename S::difference_type pos = p - s.begin();
|
||||
typename S::iterator i = s.insert(p, c);
|
||||
assert(s.__invariants());
|
||||
LIBCPP_ASSERT(s.__invariants());
|
||||
assert(s == expected);
|
||||
assert(i - s.begin() == pos);
|
||||
assert(*i == c);
|
||||
@@ -76,13 +73,4 @@ int main()
|
||||
test(s, s.begin()+6, 'C', S("a567ABC1432dcb"));
|
||||
}
|
||||
#endif
|
||||
#if _LIBCPP_DEBUG >= 1
|
||||
{
|
||||
typedef std::string S;
|
||||
S s;
|
||||
S s2;
|
||||
s.insert(s2.begin(), '1');
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ test(S s, typename S::difference_type pos, It first, It last, S expected)
|
||||
{
|
||||
typename S::const_iterator p = s.cbegin() + pos;
|
||||
typename S::iterator i = s.insert(p, first, last);
|
||||
assert(s.__invariants());
|
||||
LIBCPP_ASSERT(s.__invariants());
|
||||
assert(i - s.begin() == pos);
|
||||
assert(s == expected);
|
||||
}
|
||||
@@ -45,7 +45,7 @@ test_exceptions(S s, typename S::difference_type pos, It first, It last)
|
||||
assert(false);
|
||||
}
|
||||
catch (...) {}
|
||||
assert(s.__invariants());
|
||||
LIBCPP_ASSERT(s.__invariants());
|
||||
assert(s == aCopy);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,13 +11,10 @@
|
||||
|
||||
// iterator insert(const_iterator p, size_type n, charT c);
|
||||
|
||||
#if _LIBCPP_DEBUG >= 1
|
||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
@@ -27,7 +24,7 @@ test(S s, typename S::difference_type pos, typename S::size_type n,
|
||||
{
|
||||
typename S::const_iterator p = s.cbegin() + pos;
|
||||
typename S::iterator i = s.insert(p, n, c);
|
||||
assert(s.__invariants());
|
||||
LIBCPP_ASSERT(s.__invariants());
|
||||
assert(i - s.begin() == pos);
|
||||
assert(s == expected);
|
||||
}
|
||||
@@ -170,12 +167,4 @@ int main()
|
||||
test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111"));
|
||||
}
|
||||
#endif
|
||||
#if _LIBCPP_DEBUG >= 1
|
||||
{
|
||||
std::string s;
|
||||
std::string s2;
|
||||
s.insert(s2.begin(), 1, 'a');
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <stdexcept>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
@@ -28,7 +29,7 @@ test(S s, typename S::size_type pos, const typename S::value_type* str, S expect
|
||||
try
|
||||
{
|
||||
s.insert(pos, str);
|
||||
assert(s.__invariants());
|
||||
LIBCPP_ASSERT(s.__invariants());
|
||||
assert(pos <= old_size);
|
||||
assert(s == expected);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <stdexcept>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
@@ -29,7 +30,7 @@ test(S s, typename S::size_type pos, const typename S::value_type* str,
|
||||
try
|
||||
{
|
||||
s.insert(pos, str, n);
|
||||
assert(s.__invariants());
|
||||
LIBCPP_ASSERT(s.__invariants());
|
||||
assert(pos <= old_size);
|
||||
assert(s == expected);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <stdexcept>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
@@ -29,7 +30,7 @@ test(S s, typename S::size_type pos, typename S::size_type n,
|
||||
try
|
||||
{
|
||||
s.insert(pos, n, str);
|
||||
assert(s.__invariants());
|
||||
LIBCPP_ASSERT(s.__invariants());
|
||||
assert(pos <= old_size);
|
||||
assert(s == expected);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <stdexcept>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
@@ -28,7 +29,7 @@ test(S s, typename S::size_type pos, S str, S expected)
|
||||
try
|
||||
{
|
||||
s.insert(pos, str);
|
||||
assert(s.__invariants());
|
||||
LIBCPP_ASSERT(s.__invariants());
|
||||
assert(pos <= old_size);
|
||||
assert(s == expected);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <stdexcept>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
@@ -31,7 +32,7 @@ test(S s, typename S::size_type pos1, S str, typename S::size_type pos2,
|
||||
try
|
||||
{
|
||||
s.insert(pos1, str, pos2, n);
|
||||
assert(s.__invariants());
|
||||
LIBCPP_ASSERT(s.__invariants());
|
||||
assert(pos1 <= old_size && pos2 <= str.size());
|
||||
assert(s == expected);
|
||||
}
|
||||
@@ -51,7 +52,7 @@ test_npos(S s, typename S::size_type pos1, S str, typename S::size_type pos2, S
|
||||
try
|
||||
{
|
||||
s.insert(pos1, str, pos2);
|
||||
assert(s.__invariants());
|
||||
LIBCPP_ASSERT(s.__invariants());
|
||||
assert(pos1 <= old_size && pos2 <= str.size());
|
||||
assert(s == expected);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user