summaryrefslogtreecommitdiff
path: root/test/std/containers/sequences/vector.bool
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/containers/sequences/vector.bool')
-rw-r--r--test/std/containers/sequences/vector.bool/construct_default.pass.cpp8
-rw-r--r--test/std/containers/sequences/vector.bool/empty.fail.cpp28
-rw-r--r--test/std/containers/sequences/vector.bool/empty.pass.cpp46
-rw-r--r--test/std/containers/sequences/vector.bool/reference.swap.pass.cpp16
-rw-r--r--test/std/containers/sequences/vector.bool/size.pass.cpp62
-rw-r--r--test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp2
6 files changed, 149 insertions, 13 deletions
diff --git a/test/std/containers/sequences/vector.bool/construct_default.pass.cpp b/test/std/containers/sequences/vector.bool/construct_default.pass.cpp
index a18ba8fbaab74..0f51c219ee49a 100644
--- a/test/std/containers/sequences/vector.bool/construct_default.pass.cpp
+++ b/test/std/containers/sequences/vector.bool/construct_default.pass.cpp
@@ -24,9 +24,9 @@ void
test0()
{
#if TEST_STD_VER > 14
- static_assert((noexcept(C{})), "" );
+ static_assert((noexcept(C{})), "" );
#elif TEST_STD_VER >= 11
- static_assert((noexcept(C()) == noexcept(typename C::allocator_type())), "" );
+ static_assert((noexcept(C()) == noexcept(typename C::allocator_type())), "" );
#endif
C c;
LIBCPP_ASSERT(c.__invariants());
@@ -45,9 +45,9 @@ void
test1(const typename C::allocator_type& a)
{
#if TEST_STD_VER > 14
- static_assert((noexcept(C{typename C::allocator_type{}})), "" );
+ static_assert((noexcept(C{typename C::allocator_type{}})), "" );
#elif TEST_STD_VER >= 11
- static_assert((noexcept(C(typename C::allocator_type())) == std::is_nothrow_copy_constructible<typename C::allocator_type>::value), "" );
+ static_assert((noexcept(C(typename C::allocator_type())) == std::is_nothrow_copy_constructible<typename C::allocator_type>::value), "" );
#endif
C c(a);
LIBCPP_ASSERT(c.__invariants());
diff --git a/test/std/containers/sequences/vector.bool/empty.fail.cpp b/test/std/containers/sequences/vector.bool/empty.fail.cpp
new file mode 100644
index 0000000000000..99c245d0c09cf
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// class vector
+
+// 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 <vector>
+
+#include "test_macros.h"
+
+int main ()
+{
+ std::vector<bool> c;
+ c.empty(); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
+}
diff --git a/test/std/containers/sequences/vector.bool/empty.pass.cpp b/test/std/containers/sequences/vector.bool/empty.pass.cpp
new file mode 100644
index 0000000000000..1471c39ebb074
--- /dev/null
+++ b/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/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp b/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp
index 06351e418ac45..8fe18d4b4f84f 100644
--- a/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp
+++ b/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp
@@ -23,17 +23,17 @@ int main()
bool a[] = {false, true, false, true};
bool* an = a + sizeof(a)/sizeof(a[0]);
- std::vector<bool> v(a, an);
- std::vector<bool>::reference r1 = v[0];
- std::vector<bool>::reference r2 = v[3];
+ std::vector<bool> v(a, an);
+ std::vector<bool>::reference r1 = v[0];
+ std::vector<bool>::reference r2 = v[3];
#if TEST_STD_VER >= 11
static_assert((noexcept(v.swap(r1,r2))), "");
#endif
- assert(!r1);
- assert( r2);
- v.swap(r1, r2);
- assert( r1);
- assert(!r2);
+ assert(!r1);
+ assert( r2);
+ v.swap(r1, r2);
+ assert( r1);
+ assert(!r2);
}
diff --git a/test/std/containers/sequences/vector.bool/size.pass.cpp b/test/std/containers/sequences/vector.bool/size.pass.cpp
new file mode 100644
index 0000000000000..43330c0a5224d
--- /dev/null
+++ b/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(false);
+ 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<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(false);
+ 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/vector.bool/swap_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp
index d888af05f92f1..68d04dbb3e9ff 100644
--- a/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp
+++ b/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp
@@ -72,7 +72,7 @@ int main()
{
#if TEST_STD_VER >= 14
#if defined(_LIBCPP_VERSION)
- // 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
typedef std::vector<bool, some_alloc<bool>> C;
static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
#endif // _LIBCPP_VERSION