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:
Eric Fiselier
2016-04-28 22:28:23 +00:00
parent bda804ea25
commit 375e2f669c
101 changed files with 390 additions and 342 deletions

View File

@@ -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
}