[libcxx] r177897 - More vector::iterator debug mode tests. Run by adding to OPTIONS -D_LIBCPP_DEBUG2=1.
Howard Hinnant
hhinnant at apple.com
Mon Mar 25 13:03:19 PDT 2013
Author: hhinnant
Date: Mon Mar 25 15:03:19 2013
New Revision: 177897
URL: http://llvm.org/viewvc/llvm-project?rev=177897&view=rev
Log:
More vector::iterator debug mode tests. Run by adding to OPTIONS -D_LIBCPP_DEBUG2=1.
Added:
libcxx/trunk/test/containers/sequences/vector/db_iterators_2.pass.cpp
libcxx/trunk/test/containers/sequences/vector/db_iterators_3.pass.cpp
libcxx/trunk/test/containers/sequences/vector/db_iterators_4.pass.cpp
libcxx/trunk/test/containers/sequences/vector/db_iterators_5.pass.cpp
libcxx/trunk/test/containers/sequences/vector/db_iterators_6.pass.cpp
libcxx/trunk/test/containers/sequences/vector/db_iterators_7.pass.cpp
libcxx/trunk/test/containers/sequences/vector/db_iterators_8.pass.cpp
Modified:
libcxx/trunk/test/containers/sequences/vector/db_iterators_1.pass.cpp
Modified: libcxx/trunk/test/containers/sequences/vector/db_iterators_1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/vector/db_iterators_1.pass.cpp?rev=177897&r1=177896&r2=177897&view=diff
==============================================================================
--- libcxx/trunk/test/containers/sequences/vector/db_iterators_1.pass.cpp (original)
+++ libcxx/trunk/test/containers/sequences/vector/db_iterators_1.pass.cpp Mon Mar 25 15:03:19 2013
@@ -9,12 +9,7 @@
// <vector>
-// iterator begin();
-// iterator end();
-// const_iterator begin() const;
-// const_iterator end() const;
-// const_iterator cbegin() const;
-// const_iterator cend() const;
+// Compare iterators from different containers with == or !=.
#if _LIBCPP_DEBUG2 >= 1
@@ -50,4 +45,4 @@ int main()
{
}
-#endif
\ No newline at end of file
+#endif
Added: libcxx/trunk/test/containers/sequences/vector/db_iterators_2.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/vector/db_iterators_2.pass.cpp?rev=177897&view=auto
==============================================================================
--- libcxx/trunk/test/containers/sequences/vector/db_iterators_2.pass.cpp (added)
+++ libcxx/trunk/test/containers/sequences/vector/db_iterators_2.pass.cpp Mon Mar 25 15:03:19 2013
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Compare iterators from different containers with <.
+
+#if _LIBCPP_DEBUG2 >= 1
+
+struct X {};
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::terminate())
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+void f1()
+{
+ std::exit(0);
+}
+
+int main()
+{
+ std::set_terminate(f1);
+ typedef int T;
+ typedef std::vector<T> C;
+ C c1;
+ C c2;
+ bool b = c1.begin() < c2.begin();
+ assert(false);
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/containers/sequences/vector/db_iterators_3.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/vector/db_iterators_3.pass.cpp?rev=177897&view=auto
==============================================================================
--- libcxx/trunk/test/containers/sequences/vector/db_iterators_3.pass.cpp (added)
+++ libcxx/trunk/test/containers/sequences/vector/db_iterators_3.pass.cpp Mon Mar 25 15:03:19 2013
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Subtract iterators from different containers.
+
+#if _LIBCPP_DEBUG2 >= 1
+
+struct X {};
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::terminate())
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+void f1()
+{
+ std::exit(0);
+}
+
+int main()
+{
+ std::set_terminate(f1);
+ typedef int T;
+ typedef std::vector<T> C;
+ C c1;
+ C c2;
+ int i = c1.begin() - c2.begin();
+ assert(false);
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/containers/sequences/vector/db_iterators_4.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/vector/db_iterators_4.pass.cpp?rev=177897&view=auto
==============================================================================
--- libcxx/trunk/test/containers/sequences/vector/db_iterators_4.pass.cpp (added)
+++ libcxx/trunk/test/containers/sequences/vector/db_iterators_4.pass.cpp Mon Mar 25 15:03:19 2013
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Index iterator out of bounds.
+
+#if _LIBCPP_DEBUG2 >= 1
+
+struct X {};
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::terminate())
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+void f1()
+{
+ std::exit(0);
+}
+
+int main()
+{
+ std::set_terminate(f1);
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ C::iterator i = c.begin();
+ assert(i[0] == 0);
+ assert(i[1] == 0);
+ assert(false);
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/containers/sequences/vector/db_iterators_5.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/vector/db_iterators_5.pass.cpp?rev=177897&view=auto
==============================================================================
--- libcxx/trunk/test/containers/sequences/vector/db_iterators_5.pass.cpp (added)
+++ libcxx/trunk/test/containers/sequences/vector/db_iterators_5.pass.cpp Mon Mar 25 15:03:19 2013
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Add to iterator out of bounds.
+
+#if _LIBCPP_DEBUG2 >= 1
+
+struct X {};
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::terminate())
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+void f1()
+{
+ std::exit(0);
+}
+
+int main()
+{
+ std::set_terminate(f1);
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ C::iterator i = c.begin();
+ i += 1;
+ assert(i == c.end());
+ i = c.begin();
+ i += 2;
+ assert(false);
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/containers/sequences/vector/db_iterators_6.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/vector/db_iterators_6.pass.cpp?rev=177897&view=auto
==============================================================================
--- libcxx/trunk/test/containers/sequences/vector/db_iterators_6.pass.cpp (added)
+++ libcxx/trunk/test/containers/sequences/vector/db_iterators_6.pass.cpp Mon Mar 25 15:03:19 2013
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Decrement iterator prior to begin.
+
+#if _LIBCPP_DEBUG2 >= 1
+
+struct X {};
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::terminate())
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+void f1()
+{
+ std::exit(0);
+}
+
+int main()
+{
+ std::set_terminate(f1);
+ typedef int T;
+ typedef std::vector<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/vector/db_iterators_7.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/vector/db_iterators_7.pass.cpp?rev=177897&view=auto
==============================================================================
--- libcxx/trunk/test/containers/sequences/vector/db_iterators_7.pass.cpp (added)
+++ libcxx/trunk/test/containers/sequences/vector/db_iterators_7.pass.cpp Mon Mar 25 15:03:19 2013
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG2 >= 1
+
+struct X {};
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::terminate())
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+void f1()
+{
+ std::exit(0);
+}
+
+int main()
+{
+ std::set_terminate(f1);
+ typedef int T;
+ typedef std::vector<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/vector/db_iterators_8.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/vector/db_iterators_8.pass.cpp?rev=177897&view=auto
==============================================================================
--- libcxx/trunk/test/containers/sequences/vector/db_iterators_8.pass.cpp (added)
+++ libcxx/trunk/test/containers/sequences/vector/db_iterators_8.pass.cpp Mon Mar 25 15:03:19 2013
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG2 >= 1
+
+struct X {};
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::terminate())
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+void f1()
+{
+ std::exit(0);
+}
+
+int main()
+{
+ std::set_terminate(f1);
+ typedef int T;
+ typedef std::vector<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