[libcxx] r178565 - Some debug test cases for list.

Howard Hinnant hhinnant at apple.com
Tue Apr 2 12:53:32 PDT 2013


Author: hhinnant
Date: Tue Apr  2 14:53:32 2013
New Revision: 178565

URL: http://llvm.org/viewvc/llvm-project?rev=178565&view=rev
Log:
Some debug test cases for list.

Added:
    libcxx/trunk/test/containers/sequences/list/db_back.pass.cpp
    libcxx/trunk/test/containers/sequences/list/db_cback.pass.cpp
    libcxx/trunk/test/containers/sequences/list/db_cfront.pass.cpp
    libcxx/trunk/test/containers/sequences/list/db_front.pass.cpp
    libcxx/trunk/test/containers/sequences/list/db_iterators_1.pass.cpp
    libcxx/trunk/test/containers/sequences/list/db_iterators_6.pass.cpp
    libcxx/trunk/test/containers/sequences/list/db_iterators_7.pass.cpp
    libcxx/trunk/test/containers/sequences/list/db_iterators_8.pass.cpp

Added: libcxx/trunk/test/containers/sequences/list/db_back.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/list/db_back.pass.cpp?rev=178565&view=auto
==============================================================================
--- libcxx/trunk/test/containers/sequences/list/db_back.pass.cpp (added)
+++ libcxx/trunk/test/containers/sequences/list/db_back.pass.cpp Tue Apr  2 14:53:32 2013
@@ -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

Added: libcxx/trunk/test/containers/sequences/list/db_cback.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/list/db_cback.pass.cpp?rev=178565&view=auto
==============================================================================
--- libcxx/trunk/test/containers/sequences/list/db_cback.pass.cpp (added)
+++ libcxx/trunk/test/containers/sequences/list/db_cback.pass.cpp Tue Apr  2 14:53:32 2013
@@ -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

Added: libcxx/trunk/test/containers/sequences/list/db_cfront.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/list/db_cfront.pass.cpp?rev=178565&view=auto
==============================================================================
--- libcxx/trunk/test/containers/sequences/list/db_cfront.pass.cpp (added)
+++ libcxx/trunk/test/containers/sequences/list/db_cfront.pass.cpp Tue Apr  2 14:53:32 2013
@@ -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

Added: libcxx/trunk/test/containers/sequences/list/db_front.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/list/db_front.pass.cpp?rev=178565&view=auto
==============================================================================
--- libcxx/trunk/test/containers/sequences/list/db_front.pass.cpp (added)
+++ libcxx/trunk/test/containers/sequences/list/db_front.pass.cpp Tue Apr  2 14:53:32 2013
@@ -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

Added: libcxx/trunk/test/containers/sequences/list/db_iterators_1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/list/db_iterators_1.pass.cpp?rev=178565&view=auto
==============================================================================
--- libcxx/trunk/test/containers/sequences/list/db_iterators_1.pass.cpp (added)
+++ libcxx/trunk/test/containers/sequences/list/db_iterators_1.pass.cpp Tue Apr  2 14:53:32 2013
@@ -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

Added: libcxx/trunk/test/containers/sequences/list/db_iterators_6.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/list/db_iterators_6.pass.cpp?rev=178565&view=auto
==============================================================================
--- libcxx/trunk/test/containers/sequences/list/db_iterators_6.pass.cpp (added)
+++ libcxx/trunk/test/containers/sequences/list/db_iterators_6.pass.cpp Tue Apr  2 14:53:32 2013
@@ -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

Added: libcxx/trunk/test/containers/sequences/list/db_iterators_7.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/list/db_iterators_7.pass.cpp?rev=178565&view=auto
==============================================================================
--- libcxx/trunk/test/containers/sequences/list/db_iterators_7.pass.cpp (added)
+++ libcxx/trunk/test/containers/sequences/list/db_iterators_7.pass.cpp Tue Apr  2 14:53:32 2013
@@ -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

Added: libcxx/trunk/test/containers/sequences/list/db_iterators_8.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/list/db_iterators_8.pass.cpp?rev=178565&view=auto
==============================================================================
--- libcxx/trunk/test/containers/sequences/list/db_iterators_8.pass.cpp (added)
+++ libcxx/trunk/test/containers/sequences/list/db_iterators_8.pass.cpp Tue Apr  2 14:53:32 2013
@@ -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





More information about the cfe-commits mailing list