Cleanup _LIBCPP_DEBUG tests in std::list. More to come.

llvm-svn: 273393
This commit is contained in:
Eric Fiselier 2016-06-22 08:01:27 +00:00
parent e357c0ad3b
commit 3624fedb68
14 changed files with 122 additions and 246 deletions

View File

@ -11,8 +11,7 @@
// Call back() on empty container.
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
@ -21,11 +20,8 @@
#include <exception>
#include <cstdlib>
#include "min_allocator.h"
int main()
{
{
typedef int T;
typedef std::list<T> C;
C c(1);
@ -33,24 +29,4 @@ int main()
c.clear();
assert(c.back() == 0);
assert(false);
}
#if TEST_STD_VER >= 11
{
typedef int T;
typedef std::list<T, min_allocator<T>> C;
C c(1);
assert(c.back() == 0);
c.clear();
assert(c.back() == 0);
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@ -11,8 +11,7 @@
// Call back() on empty const container.
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
@ -21,32 +20,11 @@
#include <exception>
#include <cstdlib>
#include "min_allocator.h"
int main()
{
{
typedef int T;
typedef std::list<T> C;
const C c;
assert(c.back() == 0);
assert(false);
}
#if TEST_STD_VER >= 11
{
typedef int T;
typedef std::list<T, min_allocator<T>> C;
const C c;
assert(c.back() == 0);
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@ -11,8 +11,7 @@
// Call front() on empty const container.
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
@ -21,32 +20,11 @@
#include <exception>
#include <cstdlib>
#include "min_allocator.h"
int main()
{
{
typedef int T;
typedef std::list<T> C;
const C c;
assert(c.front() == 0);
assert(false);
}
#if TEST_STD_VER >= 11
{
typedef int T;
typedef std::list<T, min_allocator<T>> C;
const C c;
assert(c.front() == 0);
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@ -11,8 +11,7 @@
// Call front() on empty container.
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
@ -21,11 +20,8 @@
#include <exception>
#include <cstdlib>
#include "min_allocator.h"
int main()
{
{
typedef int T;
typedef std::list<T> C;
C c(1);
@ -33,24 +29,4 @@ int main()
c.clear();
assert(c.front() == 0);
assert(false);
}
#if TEST_STD_VER >= 11
{
typedef int T;
typedef std::list<T, min_allocator<T>> C;
C c(1);
assert(c.front() == 0);
c.clear();
assert(c.front() == 0);
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@ -11,8 +11,7 @@
// Decrement iterator prior to begin.
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
@ -21,11 +20,8 @@
#include <exception>
#include <cstdlib>
#include "min_allocator.h"
int main()
{
{
typedef int T;
typedef std::list<T> C;
C c(1);
@ -34,25 +30,4 @@ int main()
assert(i == c.begin());
--i;
assert(false);
}
#if TEST_STD_VER >= 11
{
typedef int T;
typedef std::list<T, min_allocator<T>> C;
C c(1);
C::iterator i = c.end();
--i;
assert(i == c.begin());
--i;
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@ -11,8 +11,7 @@
// Increment iterator past end.
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
@ -21,11 +20,8 @@
#include <exception>
#include <cstdlib>
#include "min_allocator.h"
int main()
{
{
typedef int T;
typedef std::list<T> C;
C c(1);
@ -34,25 +30,4 @@ int main()
assert(i == c.end());
++i;
assert(false);
}
#if TEST_STD_VER >= 11
{
typedef int T;
typedef std::list<T, min_allocator<T>> C;
C c(1);
C::iterator i = c.begin();
++i;
assert(i == c.end());
++i;
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@ -11,8 +11,7 @@
// Dereference non-dereferenceable iterator.
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
@ -21,34 +20,12 @@
#include <exception>
#include <cstdlib>
#include "min_allocator.h"
int main()
{
{
typedef int T;
typedef std::list<T> C;
C c(1);
C::iterator i = c.end();
T j = *i;
assert(false);
}
#if TEST_STD_VER >= 11
{
typedef int T;
typedef std::list<T, min_allocator<T>> C;
C c(1);
C::iterator i = c.end();
T j = *i;
assert(false);
}
#endif
}
#else
int main()
{
}
#endif

View File

@ -7,13 +7,14 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11
// UNSUPPORTED: c++98, c++03
// UNSUPPORTED: libcpp-no-exceptions
// <list>
// Operations on "NULL" iterators
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) do { if (!x) throw 1; } while(0)
#include <list>
@ -56,11 +57,3 @@ int main()
assert(lib_asserts == 4);
}
}
#else
int main()
{
}
#endif

View File

@ -0,0 +1,44 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <list>
// template <class... Args> void emplace(const_iterator p, Args&&... args);
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
#include <cstdlib>
#include <cassert>
class A
{
int i_;
double d_;
A(const A&);
A& operator=(const A&);
public:
A(int i, double d)
: i_(i), d_(d) {}
int geti() const {return i_;}
double getd() const {return d_;}
};
int main()
{
std::list<A> c1;
std::list<A> c2;
std::list<A>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
assert(false);
}

View File

@ -0,0 +1,27 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <list>
// iterator insert(const_iterator position, value_type&& x);
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
#include <cstdlib>
#include <cassert>
int main()
{
std::list<int> v1(3);
std::list<int> v2(3);
v1.insert(v2.begin(), 4);
assert(false);
}

View File

@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <list>
// void pop_back();
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
#include <cstdlib>
#include <cassert>
int main()
{
int a[] = {1, 2, 3};
std::list<int> c(a, a+3);
c.pop_back();
assert(c == std::list<int>(a, a+2));
c.pop_back();
assert(c == std::list<int>(a, a+1));
c.pop_back();
assert(c.empty());
c.pop_back(); // operation under test
assert(false);
}

View File

@ -7,17 +7,17 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <list>
// template <class... Args> void emplace(const_iterator p, Args&&... args);
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#endif
#include <list>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
class A
@ -37,7 +37,6 @@ public:
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
std::list<A> c;
c.emplace(c.cbegin(), 2, 3.5);
@ -51,17 +50,6 @@ int main()
assert(c.back().geti() == 3);
assert(c.back().getd() == 4.5);
}
#if _LIBCPP_DEBUG >= 1
{
std::list<A> c1;
std::list<A> c2;
std::list<A>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
assert(false);
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
#if TEST_STD_VER >= 11
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
std::list<A, min_allocator<A>> c;
c.emplace(c.cbegin(), 2, 3.5);
@ -75,14 +63,5 @@ int main()
assert(c.back().geti() == 3);
assert(c.back().getd() == 4.5);
}
#if _LIBCPP_DEBUG >= 1
{
std::list<A, min_allocator<A>> c1;
std::list<A, min_allocator<A>> c2;
std::list<A, min_allocator<A>>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
assert(false);
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
#endif
}

View File

@ -7,14 +7,12 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <list>
// iterator insert(const_iterator position, value_type&& x);
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#endif
#include <list>
#include <cassert>
@ -23,7 +21,6 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
std::list<MoveOnly> l1;
l1.insert(l1.cend(), MoveOnly(1));
@ -34,17 +31,6 @@ int main()
assert(l1.front() == MoveOnly(2));
assert(l1.back() == MoveOnly(1));
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
#if _LIBCPP_DEBUG >= 1
{
std::list<int> v1(3);
std::list<int> v2(3);
v1.insert(v2.begin(), 4);
assert(false);
}
#endif
#if TEST_STD_VER >= 11
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
std::list<MoveOnly, min_allocator<MoveOnly>> l1;
l1.insert(l1.cend(), MoveOnly(1));
@ -55,14 +41,4 @@ int main()
assert(l1.front() == MoveOnly(2));
assert(l1.back() == MoveOnly(1));
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
#if _LIBCPP_DEBUG >= 1
{
std::list<int, min_allocator<int>> v1(3);
std::list<int, min_allocator<int>> v2(3);
v1.insert(v2.begin(), 4);
assert(false);
}
#endif
#endif
}

View File

@ -11,13 +11,10 @@
// void pop_back();
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#endif
#include <list>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
int main()
@ -31,10 +28,6 @@ int main()
assert(c == std::list<int>(a, a+1));
c.pop_back();
assert(c.empty());
#if _LIBCPP_DEBUG >= 1
c.pop_back();
assert(false);
#endif
}
#if TEST_STD_VER >= 11
{
@ -46,10 +39,6 @@ int main()
assert((c == std::list<int, min_allocator<int>>(a, a+1)));
c.pop_back();
assert(c.empty());
#if _LIBCPP_DEBUG >= 1
c.pop_back();
assert(false);
#endif
}
#endif
}