Some debug test cases for list.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@178565 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant 2013-04-02 19:53:32 +00:00
parent f6bdda044c
commit d4c96a6c89
8 changed files with 324 additions and 0 deletions

View File

@ -0,0 +1,41 @@
//===----------------------------------------------------------------------===//
//
// 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.
#if _LIBCPP_DEBUG2 >= 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);
}
#else
int main()
{
}
#endif

View File

@ -0,0 +1,39 @@
//===----------------------------------------------------------------------===//
//
// 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.
#if _LIBCPP_DEBUG2 >= 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);
}
#else
int main()
{
}
#endif

View File

@ -0,0 +1,39 @@
//===----------------------------------------------------------------------===//
//
// 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.
#if _LIBCPP_DEBUG2 >= 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);
}
#else
int main()
{
}
#endif

View File

@ -0,0 +1,41 @@
//===----------------------------------------------------------------------===//
//
// 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.
#if _LIBCPP_DEBUG2 >= 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);
}
#else
int main()
{
}
#endif

View File

@ -0,0 +1,40 @@
//===----------------------------------------------------------------------===//
//
// 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>
// Compare iterators from different containers with == or !=.
#if _LIBCPP_DEBUG2 >= 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 c1;
C c2;
bool b = c1.begin() != c2.begin();
assert(false);
}
#else
int main()
{
}
#endif

View File

@ -0,0 +1,42 @@
//===----------------------------------------------------------------------===//
//
// 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.
#if _LIBCPP_DEBUG2 >= 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);
}
#else
int main()
{
}
#endif

View File

@ -0,0 +1,42 @@
//===----------------------------------------------------------------------===//
//
// 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.
#if _LIBCPP_DEBUG2 >= 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);
}
#else
int main()
{
}
#endif

View File

@ -0,0 +1,40 @@
//===----------------------------------------------------------------------===//
//
// 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.
#if _LIBCPP_DEBUG2 >= 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);
}
#else
int main()
{
}
#endif