summaryrefslogtreecommitdiffstats
path: root/libcxx/test
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2013-03-25 20:03:19 +0000
committerHoward Hinnant <hhinnant@apple.com>2013-03-25 20:03:19 +0000
commit35b3b545482ae8c90f9467ba6623294592d292ea (patch)
tree86e9bebec42cee3d17f67d5510a9f3b4e4818be5 /libcxx/test
parenta6c51833ef101651327b724988df78cc5d43dde0 (diff)
downloadbcm5719-llvm-35b3b545482ae8c90f9467ba6623294592d292ea.tar.gz
bcm5719-llvm-35b3b545482ae8c90f9467ba6623294592d292ea.zip
More vector::iterator debug mode tests. Run by adding to OPTIONS -D_LIBCPP_DEBUG2=1.
llvm-svn: 177897
Diffstat (limited to 'libcxx/test')
-rw-r--r--libcxx/test/containers/sequences/vector/db_iterators_1.pass.cpp9
-rw-r--r--libcxx/test/containers/sequences/vector/db_iterators_2.pass.cpp48
-rw-r--r--libcxx/test/containers/sequences/vector/db_iterators_3.pass.cpp48
-rw-r--r--libcxx/test/containers/sequences/vector/db_iterators_4.pass.cpp49
-rw-r--r--libcxx/test/containers/sequences/vector/db_iterators_5.pass.cpp51
-rw-r--r--libcxx/test/containers/sequences/vector/db_iterators_6.pass.cpp50
-rw-r--r--libcxx/test/containers/sequences/vector/db_iterators_7.pass.cpp50
-rw-r--r--libcxx/test/containers/sequences/vector/db_iterators_8.pass.cpp48
8 files changed, 346 insertions, 7 deletions
diff --git a/libcxx/test/containers/sequences/vector/db_iterators_1.pass.cpp b/libcxx/test/containers/sequences/vector/db_iterators_1.pass.cpp
index 6fff0ba80b5..6450e87616c 100644
--- a/libcxx/test/containers/sequences/vector/db_iterators_1.pass.cpp
+++ b/libcxx/test/containers/sequences/vector/db_iterators_1.pass.cpp
@@ -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
diff --git a/libcxx/test/containers/sequences/vector/db_iterators_2.pass.cpp b/libcxx/test/containers/sequences/vector/db_iterators_2.pass.cpp
new file mode 100644
index 00000000000..a36209b1645
--- /dev/null
+++ b/libcxx/test/containers/sequences/vector/db_iterators_2.pass.cpp
@@ -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
diff --git a/libcxx/test/containers/sequences/vector/db_iterators_3.pass.cpp b/libcxx/test/containers/sequences/vector/db_iterators_3.pass.cpp
new file mode 100644
index 00000000000..b57ccf02277
--- /dev/null
+++ b/libcxx/test/containers/sequences/vector/db_iterators_3.pass.cpp
@@ -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
diff --git a/libcxx/test/containers/sequences/vector/db_iterators_4.pass.cpp b/libcxx/test/containers/sequences/vector/db_iterators_4.pass.cpp
new file mode 100644
index 00000000000..68d0a5d3e9f
--- /dev/null
+++ b/libcxx/test/containers/sequences/vector/db_iterators_4.pass.cpp
@@ -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
diff --git a/libcxx/test/containers/sequences/vector/db_iterators_5.pass.cpp b/libcxx/test/containers/sequences/vector/db_iterators_5.pass.cpp
new file mode 100644
index 00000000000..8c0614e502f
--- /dev/null
+++ b/libcxx/test/containers/sequences/vector/db_iterators_5.pass.cpp
@@ -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
diff --git a/libcxx/test/containers/sequences/vector/db_iterators_6.pass.cpp b/libcxx/test/containers/sequences/vector/db_iterators_6.pass.cpp
new file mode 100644
index 00000000000..c85a2514f9c
--- /dev/null
+++ b/libcxx/test/containers/sequences/vector/db_iterators_6.pass.cpp
@@ -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
diff --git a/libcxx/test/containers/sequences/vector/db_iterators_7.pass.cpp b/libcxx/test/containers/sequences/vector/db_iterators_7.pass.cpp
new file mode 100644
index 00000000000..7d7c4bfdd52
--- /dev/null
+++ b/libcxx/test/containers/sequences/vector/db_iterators_7.pass.cpp
@@ -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
diff --git a/libcxx/test/containers/sequences/vector/db_iterators_8.pass.cpp b/libcxx/test/containers/sequences/vector/db_iterators_8.pass.cpp
new file mode 100644
index 00000000000..e6bb3b7ddf0
--- /dev/null
+++ b/libcxx/test/containers/sequences/vector/db_iterators_8.pass.cpp
@@ -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
OpenPOWER on IntegriCloud