aboutsummaryrefslogtreecommitdiff
path: root/test/std/containers/sequences/deque
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/containers/sequences/deque')
-rw-r--r--test/std/containers/sequences/deque/deque.capacity/empty.fail.cpp28
-rw-r--r--test/std/containers/sequences/deque/deque.capacity/empty.pass.cpp46
-rw-r--r--test/std/containers/sequences/deque/deque.capacity/size.pass.cpp62
-rw-r--r--test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp2
-rw-r--r--test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp10
-rw-r--r--test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp10
-rw-r--r--test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp2
7 files changed, 148 insertions, 12 deletions
diff --git a/test/std/containers/sequences/deque/deque.capacity/empty.fail.cpp b/test/std/containers/sequences/deque/deque.capacity/empty.fail.cpp
new file mode 100644
index 0000000000000..adfd5f2d8167f
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.capacity/empty.fail.cpp
@@ -0,0 +1,28 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// 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;
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
+
+#include <deque>
+
+#include "test_macros.h"
+
+int main ()
+{
+ std::deque<int> c;
+ c.empty(); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
+}
diff --git a/test/std/containers/sequences/deque/deque.capacity/empty.pass.cpp b/test/std/containers/sequences/deque/deque.capacity/empty.pass.cpp
new file mode 100644
index 0000000000000..629a51cab95b2
--- /dev/null
+++ b/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/test/std/containers/sequences/deque/deque.capacity/size.pass.cpp b/test/std/containers/sequences/deque/deque.capacity/size.pass.cpp
new file mode 100644
index 0000000000000..4974fc74d0b18
--- /dev/null
+++ b/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/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp
index fdf67d23a12d9..baae755bc27d6 100644
--- a/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp
+++ b/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp
@@ -45,9 +45,9 @@ int main()
typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, "");
}
-#endif // _LIBCPP_VERSION
{
typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C;
static_assert(!std::is_nothrow_move_constructible<C>::value, "");
}
+#endif // _LIBCPP_VERSION
}
diff --git a/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp
index db22086fd4c93..4c1e15f7acb87 100644
--- a/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp
+++ b/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp
@@ -80,17 +80,17 @@ int main()
assert(false);
}
catch (...) {
- gCopyConstructorShouldThow = false;
+ gCopyConstructorShouldThow = false;
assert(vec==vec2);
}
- }
+ }
- {
- typedef std::deque<CMyClass, test_allocator<CMyClass> > C;
+ {
+ typedef std::deque<CMyClass, test_allocator<CMyClass> > C;
C vec;
C vec2(vec);
- C::allocator_type::throw_after = 1;
+ C::allocator_type::throw_after = 1;
try {
vec.push_back(instance);
assert(false);
diff --git a/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp
index 7a90c8a759620..0688ed025089d 100644
--- a/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp
+++ b/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp
@@ -80,17 +80,17 @@ int main()
assert(false);
}
catch (...) {
- gCopyConstructorShouldThow = false;
+ gCopyConstructorShouldThow = false;
assert(vec==vec2);
}
- }
+ }
- {
- typedef std::deque<CMyClass, test_allocator<CMyClass> > C;
+ {
+ typedef std::deque<CMyClass, test_allocator<CMyClass> > C;
C vec;
C vec2(vec);
- C::allocator_type::throw_after = 1;
+ C::allocator_type::throw_after = 1;
try {
vec.push_front(instance);
assert(false);
diff --git a/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp
index 0db30a0312829..01a10964b77f1 100644
--- a/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp
+++ b/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp
@@ -72,7 +72,7 @@ int main()
{
typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C;
#if TEST_STD_VER >= 14
- // In c++14, if POCS is set, swapping the allocator is required not to throw
+ // In C++14, if POCS is set, swapping the allocator is required not to throw
static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
#else
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");