Cleanup _LIBCPP_DEBUG tests in std::list. More to come.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273393 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
32
test/libcxx/containers/sequences/list/db_back.pass.cpp
Normal file
32
test/libcxx/containers/sequences/list/db_back.pass.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// Call back() on empty container.
|
||||
|
||||
#define _LIBCPP_DEBUG 1
|
||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
||||
|
||||
#include <list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::list<T> C;
|
||||
C c(1);
|
||||
assert(c.back() == 0);
|
||||
c.clear();
|
||||
assert(c.back() == 0);
|
||||
assert(false);
|
||||
}
|
||||
30
test/libcxx/containers/sequences/list/db_cback.pass.cpp
Normal file
30
test/libcxx/containers/sequences/list/db_cback.pass.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// Call back() on empty const container.
|
||||
|
||||
#define _LIBCPP_DEBUG 1
|
||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
||||
|
||||
#include <list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::list<T> C;
|
||||
const C c;
|
||||
assert(c.back() == 0);
|
||||
assert(false);
|
||||
}
|
||||
30
test/libcxx/containers/sequences/list/db_cfront.pass.cpp
Normal file
30
test/libcxx/containers/sequences/list/db_cfront.pass.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// Call front() on empty const container.
|
||||
|
||||
#define _LIBCPP_DEBUG 1
|
||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
||||
|
||||
#include <list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::list<T> C;
|
||||
const C c;
|
||||
assert(c.front() == 0);
|
||||
assert(false);
|
||||
}
|
||||
32
test/libcxx/containers/sequences/list/db_front.pass.cpp
Normal file
32
test/libcxx/containers/sequences/list/db_front.pass.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// Call front() on empty container.
|
||||
|
||||
#define _LIBCPP_DEBUG 1
|
||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
||||
|
||||
#include <list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::list<T> C;
|
||||
C c(1);
|
||||
assert(c.front() == 0);
|
||||
c.clear();
|
||||
assert(c.front() == 0);
|
||||
assert(false);
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
// Decrement iterator prior to begin.
|
||||
|
||||
#define _LIBCPP_DEBUG 1
|
||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
||||
|
||||
#include <list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::list<T> C;
|
||||
C c(1);
|
||||
C::iterator i = c.end();
|
||||
--i;
|
||||
assert(i == c.begin());
|
||||
--i;
|
||||
assert(false);
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
// Increment iterator past end.
|
||||
|
||||
#define _LIBCPP_DEBUG 1
|
||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
||||
|
||||
#include <list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::list<T> C;
|
||||
C c(1);
|
||||
C::iterator i = c.begin();
|
||||
++i;
|
||||
assert(i == c.end());
|
||||
++i;
|
||||
assert(false);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// Dereference non-dereferenceable iterator.
|
||||
|
||||
#define _LIBCPP_DEBUG 1
|
||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
||||
|
||||
#include <list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::list<T> C;
|
||||
C c(1);
|
||||
C::iterator i = c.end();
|
||||
T j = *i;
|
||||
assert(false);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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
|
||||
// UNSUPPORTED: libcpp-no-exceptions
|
||||
|
||||
// <list>
|
||||
|
||||
// Operations on "NULL" iterators
|
||||
|
||||
#define _LIBCPP_DEBUG 1
|
||||
#define _LIBCPP_ASSERT(x, m) do { if (!x) throw 1; } while(0)
|
||||
|
||||
#include <list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
struct S { int val; };
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
unsigned lib_asserts;
|
||||
|
||||
typedef S T;
|
||||
typedef std::list<T> C;
|
||||
C::iterator i{};
|
||||
C::const_iterator ci{};
|
||||
|
||||
lib_asserts = 0;
|
||||
try { ++i; } catch (int) { ++lib_asserts; }
|
||||
try { i++; } catch (int) { ++lib_asserts; }
|
||||
try { ++ci; } catch (int) { ++lib_asserts; }
|
||||
try { ci++; } catch (int) { ++lib_asserts; }
|
||||
assert(lib_asserts == 4);
|
||||
|
||||
lib_asserts = 0;
|
||||
try { --i; } catch (int) { ++lib_asserts; }
|
||||
try { i--; } catch (int) { ++lib_asserts; }
|
||||
try { --ci; } catch (int) { ++lib_asserts; }
|
||||
try { ci--; } catch (int) { ++lib_asserts; }
|
||||
assert(lib_asserts == 4);
|
||||
|
||||
lib_asserts = 0;
|
||||
try { *i; } catch (int) { ++lib_asserts; }
|
||||
try { *ci; } catch (int) { ++lib_asserts; }
|
||||
try { (void) i->val; } catch (int) { ++lib_asserts; }
|
||||
try { (void) ci->val; } catch (int) { ++lib_asserts; }
|
||||
assert(lib_asserts == 4);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user