summaryrefslogtreecommitdiffstats
path: root/libcxx
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2017-11-15 01:33:33 +0000
committerMarshall Clow <mclow.lists@gmail.com>2017-11-15 01:33:33 +0000
commit4cb7d78130719390849486b0dee1ed01fba4b033 (patch)
tree3125bd4adfaa1058be44d427758f68736f0a717a /libcxx
parent659d5fbe9993c8fdf6116a4a9dc886bc1643e0ac (diff)
downloadbcm5719-llvm-4cb7d78130719390849486b0dee1ed01fba4b033.tar.gz
bcm5719-llvm-4cb7d78130719390849486b0dee1ed01fba4b033.zip
Added tests for xxx.size() and xxx.empty() for all the sequence containers
llvm-svn: 318244
Diffstat (limited to 'libcxx')
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.capacity/empty.pass.cpp46
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.capacity/size.pass.cpp62
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/empty.pass.cpp46
-rw-r--r--libcxx/test/std/containers/sequences/list/list.capacity/empty.pass.cpp46
-rw-r--r--libcxx/test/std/containers/sequences/list/list.capacity/size.pass.cpp62
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/empty.pass.cpp46
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/size.pass.cpp62
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.capacity/empty.pass.cpp46
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.capacity/size.pass.cpp62
9 files changed, 478 insertions, 0 deletions
diff --git a/libcxx/test/std/containers/sequences/deque/deque.capacity/empty.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.capacity/empty.pass.cpp
new file mode 100644
index 00000000000..629a51cab95
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.capacity/empty.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// class deque
+
+// bool empty() const noexcept;
+
+#include <deque>
+#include <cassert>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::deque<int> C;
+ C c;
+ ASSERT_NOEXCEPT(c.empty());
+ assert(c.empty());
+ c.push_back(C::value_type(1));
+ assert(!c.empty());
+ c.clear();
+ assert(c.empty());
+ }
+#if TEST_STD_VER >= 11
+ {
+ typedef std::deque<int, min_allocator<int>> C;
+ C c;
+ ASSERT_NOEXCEPT(c.empty());
+ assert(c.empty());
+ c.push_back(C::value_type(1));
+ assert(!c.empty());
+ c.clear();
+ assert(c.empty());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.capacity/size.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.capacity/size.pass.cpp
new file mode 100644
index 00000000000..4974fc74d0b
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.capacity/size.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// class deque
+
+// size_type size() const noexcept;
+
+#include <deque>
+#include <cassert>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::deque<int> C;
+ C c;
+ ASSERT_NOEXCEPT(c.size());
+ assert(c.size() == 0);
+ c.push_back(C::value_type(2));
+ assert(c.size() == 1);
+ c.push_back(C::value_type(1));
+ assert(c.size() == 2);
+ c.push_back(C::value_type(3));
+ assert(c.size() == 3);
+ c.erase(c.begin());
+ assert(c.size() == 2);
+ c.erase(c.begin());
+ assert(c.size() == 1);
+ c.erase(c.begin());
+ assert(c.size() == 0);
+ }
+#if TEST_STD_VER >= 11
+ {
+ typedef std::deque<int, min_allocator<int>> C;
+ C c;
+ ASSERT_NOEXCEPT(c.size());
+ assert(c.size() == 0);
+ c.push_back(C::value_type(2));
+ assert(c.size() == 1);
+ c.push_back(C::value_type(1));
+ assert(c.size() == 2);
+ c.push_back(C::value_type(3));
+ assert(c.size() == 3);
+ c.erase(c.begin());
+ assert(c.size() == 2);
+ c.erase(c.begin());
+ assert(c.size() == 1);
+ c.erase(c.begin());
+ assert(c.size() == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/empty.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/empty.pass.cpp
new file mode 100644
index 00000000000..1226e68ed3c
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/empty.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// class forward_list
+
+// bool empty() const noexcept;
+
+#include <forward_list>
+#include <cassert>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::forward_list<int> C;
+ C c;
+ ASSERT_NOEXCEPT(c.empty());
+ assert(c.empty());
+ c.push_front(C::value_type(1));
+ assert(!c.empty());
+ c.clear();
+ assert(c.empty());
+ }
+#if TEST_STD_VER >= 11
+ {
+ typedef std::forward_list<int, min_allocator<int>> C;
+ C c;
+ ASSERT_NOEXCEPT(c.empty());
+ assert(c.empty());
+ c.push_front(C::value_type(1));
+ assert(!c.empty());
+ c.clear();
+ assert(c.empty());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.capacity/empty.pass.cpp b/libcxx/test/std/containers/sequences/list/list.capacity/empty.pass.cpp
new file mode 100644
index 00000000000..b564990f2d0
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.capacity/empty.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class list
+
+// bool empty() const noexcept;
+
+#include <list>
+#include <cassert>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::list<int> C;
+ C c;
+ ASSERT_NOEXCEPT(c.empty());
+ assert(c.empty());
+ c.push_back(C::value_type(1));
+ assert(!c.empty());
+ c.clear();
+ assert(c.empty());
+ }
+#if TEST_STD_VER >= 11
+ {
+ typedef std::list<int, min_allocator<int>> C;
+ C c;
+ ASSERT_NOEXCEPT(c.empty());
+ assert(c.empty());
+ c.push_back(C::value_type(1));
+ assert(!c.empty());
+ c.clear();
+ assert(c.empty());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.capacity/size.pass.cpp b/libcxx/test/std/containers/sequences/list/list.capacity/size.pass.cpp
new file mode 100644
index 00000000000..bddaeb5ac04
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.capacity/size.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class list
+
+// size_type size() const noexcept;
+
+#include <list>
+#include <cassert>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::list<int> C;
+ C c;
+ ASSERT_NOEXCEPT(c.size());
+ assert(c.size() == 0);
+ c.push_back(C::value_type(2));
+ assert(c.size() == 1);
+ c.push_back(C::value_type(1));
+ assert(c.size() == 2);
+ c.push_back(C::value_type(3));
+ assert(c.size() == 3);
+ c.erase(c.begin());
+ assert(c.size() == 2);
+ c.erase(c.begin());
+ assert(c.size() == 1);
+ c.erase(c.begin());
+ assert(c.size() == 0);
+ }
+#if TEST_STD_VER >= 11
+ {
+ typedef std::list<int, min_allocator<int>> C;
+ C c;
+ ASSERT_NOEXCEPT(c.size());
+ assert(c.size() == 0);
+ c.push_back(C::value_type(2));
+ assert(c.size() == 1);
+ c.push_back(C::value_type(1));
+ assert(c.size() == 2);
+ c.push_back(C::value_type(3));
+ assert(c.size() == 3);
+ c.erase(c.begin());
+ assert(c.size() == 2);
+ c.erase(c.begin());
+ assert(c.size() == 1);
+ c.erase(c.begin());
+ assert(c.size() == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/empty.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/empty.pass.cpp
new file mode 100644
index 00000000000..1471c39ebb0
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/empty.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class vector
+
+// bool empty() const noexcept;
+
+#include <vector>
+#include <cassert>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::vector<bool> C;
+ C c;
+ ASSERT_NOEXCEPT(c.empty());
+ assert(c.empty());
+ c.push_back(false);
+ assert(!c.empty());
+ c.clear();
+ assert(c.empty());
+ }
+#if TEST_STD_VER >= 11
+ {
+ typedef std::vector<bool, min_allocator<bool>> C;
+ C c;
+ ASSERT_NOEXCEPT(c.empty());
+ assert(c.empty());
+ c.push_back(false);
+ assert(!c.empty());
+ c.clear();
+ assert(c.empty());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/size.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/size.pass.cpp
new file mode 100644
index 00000000000..a1dcfd69ee3
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/size.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class vector
+
+// size_type size() const noexcept;
+
+#include <vector>
+#include <cassert>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::vector<bool> C;
+ C c;
+ ASSERT_NOEXCEPT(c.size());
+ assert(c.size() == 0);
+ c.push_back(false);
+ assert(c.size() == 1);
+ c.push_back(true);
+ assert(c.size() == 2);
+ c.push_back(C::value_type(3));
+ assert(true);
+ c.erase(c.begin());
+ assert(c.size() == 2);
+ c.erase(c.begin());
+ assert(c.size() == 1);
+ c.erase(c.begin());
+ assert(c.size() == 0);
+ }
+#if TEST_STD_VER >= 11
+ {
+ typedef std::vector<bool, min_allocator<bool>> C;
+ C c;
+ ASSERT_NOEXCEPT(c.size());
+ assert(c.size() == 0);
+ c.push_back(false);
+ assert(c.size() == 1);
+ c.push_back(true);
+ assert(c.size() == 2);
+ c.push_back(C::value_type(3));
+ assert(true);
+ c.erase(c.begin());
+ assert(c.size() == 2);
+ c.erase(c.begin());
+ assert(c.size() == 1);
+ c.erase(c.begin());
+ assert(c.size() == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/empty.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/empty.pass.cpp
new file mode 100644
index 00000000000..d81683133f5
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/empty.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class vector
+
+// bool empty() const noexcept;
+
+#include <vector>
+#include <cassert>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::vector<int> C;
+ C c;
+ ASSERT_NOEXCEPT(c.empty());
+ assert(c.empty());
+ c.push_back(C::value_type(1));
+ assert(!c.empty());
+ c.clear();
+ assert(c.empty());
+ }
+#if TEST_STD_VER >= 11
+ {
+ typedef std::vector<int, min_allocator<int>> C;
+ C c;
+ ASSERT_NOEXCEPT(c.empty());
+ assert(c.empty());
+ c.push_back(C::value_type(1));
+ assert(!c.empty());
+ c.clear();
+ assert(c.empty());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/size.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/size.pass.cpp
new file mode 100644
index 00000000000..71f531c4888
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/size.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class vector
+
+// size_type size() const noexcept;
+
+#include <vector>
+#include <cassert>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::vector<int> C;
+ C c;
+ ASSERT_NOEXCEPT(c.size());
+ assert(c.size() == 0);
+ c.push_back(C::value_type(2));
+ assert(c.size() == 1);
+ c.push_back(C::value_type(1));
+ assert(c.size() == 2);
+ c.push_back(C::value_type(3));
+ assert(c.size() == 3);
+ c.erase(c.begin());
+ assert(c.size() == 2);
+ c.erase(c.begin());
+ assert(c.size() == 1);
+ c.erase(c.begin());
+ assert(c.size() == 0);
+ }
+#if TEST_STD_VER >= 11
+ {
+ typedef std::vector<int, min_allocator<int>> C;
+ C c;
+ ASSERT_NOEXCEPT(c.size());
+ assert(c.size() == 0);
+ c.push_back(C::value_type(2));
+ assert(c.size() == 1);
+ c.push_back(C::value_type(1));
+ assert(c.size() == 2);
+ c.push_back(C::value_type(3));
+ assert(c.size() == 3);
+ c.erase(c.begin());
+ assert(c.size() == 2);
+ c.erase(c.begin());
+ assert(c.size() == 1);
+ c.erase(c.begin());
+ assert(c.size() == 0);
+ }
+#endif
+}
OpenPOWER on IntegriCloud