diff options
Diffstat (limited to 'test/std/containers/sequences/vector.bool')
17 files changed, 94 insertions, 55 deletions
diff --git a/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp b/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp index ac7a2ce38adf..60146a88b3b5 100644 --- a/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // void assign(initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector<bool> d; d.assign({true, false, false, true}); @@ -28,7 +29,6 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> d; d.assign({true, false, false, true}); @@ -38,6 +38,4 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/vector.bool/assign_move.pass.cpp b/test/std/containers/sequences/vector.bool/assign_move.pass.cpp index f07c1d90059d..13cd65f33123 100644 --- a/test/std/containers/sequences/vector.bool/assign_move.pass.cpp +++ b/test/std/containers/sequences/vector.bool/assign_move.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector& operator=(vector&& c); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5)); std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5)); @@ -61,7 +62,6 @@ int main() assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); } -#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{}); std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{}); @@ -76,6 +76,4 @@ int main() assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp index 4f860dabac95..4e71df37421e 100644 --- a/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp @@ -31,14 +31,16 @@ struct some_alloc int main() { +#if defined(_LIBCPP_VERSION) { typedef std::vector<bool> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::vector<bool, test_allocator<bool>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::vector<bool, other_allocator<bool>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); diff --git a/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp index b8ff33c5d2e8..5f1f5d10485d 100644 --- a/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp @@ -41,8 +41,10 @@ int main() typedef std::vector<bool, other_allocator<bool>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::vector<bool, some_alloc<bool>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/sequences/vector.bool/emplace.pass.cpp b/test/std/containers/sequences/vector.bool/emplace.pass.cpp index ccdce913c73c..8a1ed033488a 100644 --- a/test/std/containers/sequences/vector.bool/emplace.pass.cpp +++ b/test/std/containers/sequences/vector.bool/emplace.pass.cpp @@ -34,7 +34,7 @@ int main() assert(c.front() == false); assert(c.back() == true); - i = c.emplace(c.cbegin()+1, 1 == 1); + i = c.emplace(c.cbegin()+1, true); assert(i == c.begin()+1); assert(c.size() == 3); assert(c.front() == false); @@ -56,7 +56,7 @@ int main() assert(c.front() == false); assert(c.back() == true); - i = c.emplace(c.cbegin()+1, 1 == 1); + i = c.emplace(c.cbegin()+1, true); assert(i == c.begin()+1); assert(c.size() == 3); assert(c.size() == 3); diff --git a/test/std/containers/sequences/vector.bool/enabled_hash.pass.cpp b/test/std/containers/sequences/vector.bool/enabled_hash.pass.cpp new file mode 100644 index 000000000000..f8a8dbd8d6d4 --- /dev/null +++ b/test/std/containers/sequences/vector.bool/enabled_hash.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// <vector> + +// Test that <vector> provides all of the arithmetic, enum, and pointer +// hash specializations. + +#include <vector> + +#include "poisoned_hash_helper.hpp" +#include "min_allocator.h" + +int main() { + test_library_hash_specializations_available(); + { + test_hash_enabled_for_type<std::vector<bool> >(); + test_hash_enabled_for_type<std::vector<bool, min_allocator<bool>>>(); + } +} diff --git a/test/std/containers/sequences/vector.bool/find.pass.cpp b/test/std/containers/sequences/vector.bool/find.pass.cpp index ffe844e0079c..d5c3f458c634 100644 --- a/test/std/containers/sequences/vector.bool/find.pass.cpp +++ b/test/std/containers/sequences/vector.bool/find.pass.cpp @@ -12,7 +12,7 @@ // std::find with vector<bool>::iterator -// http://llvm.org/bugs/show_bug.cgi?id=16816 +// https://bugs.llvm.org/show_bug.cgi?id=16816 #include <vector> #include <algorithm> diff --git a/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp b/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp index 07bae0eb7089..a850fa2f1cdd 100644 --- a/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector(initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector<bool> d = {true, false, false, true}; assert(d.size() == 4); @@ -27,7 +28,6 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> d = {true, false, false, true}; assert(d.size() == 4); @@ -36,6 +36,4 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp b/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp index 5f7f5144f841..9a2df4290e77 100644 --- a/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp +++ b/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector(initializer_list<value_type> il, const Allocator& a = allocator_type()); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector<bool, test_allocator<bool>> d({true, false, false, true}, test_allocator<bool>(3)); assert(d.get_allocator() == test_allocator<bool>(3)); @@ -29,7 +30,6 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> d({true, false, false, true}, min_allocator<bool>()); assert(d.get_allocator() == min_allocator<bool>()); @@ -39,6 +39,4 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp b/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp index 3a176d94e860..df4cb199b8fd 100644 --- a/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // iterator insert(const_iterator p, initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector<bool> d(10, true); std::vector<bool>::iterator i = d.insert(d.cbegin() + 2, {false, true, true, false}); @@ -39,7 +40,6 @@ int main() assert(d[12] == true); assert(d[13] == true); } -#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> d(10, true); std::vector<bool, min_allocator<bool>>::iterator i = d.insert(d.cbegin() + 2, {false, true, true, false}); @@ -60,6 +60,4 @@ int main() assert(d[12] == true); assert(d[13] == true); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/vector.bool/move.pass.cpp b/test/std/containers/sequences/vector.bool/move.pass.cpp index f3a11ec562c0..f189e2b97092 100644 --- a/test/std/containers/sequences/vector.bool/move.pass.cpp +++ b/test/std/containers/sequences/vector.bool/move.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector(vector&& c); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5)); std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5)); @@ -45,7 +46,6 @@ int main() assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); } -#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{}); std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{}); @@ -59,6 +59,4 @@ int main() assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp b/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp index 7aaa7c55550b..b3b6f964966b 100644 --- a/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp +++ b/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector(vector&& c, const allocator_type& a); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5)); std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5)); @@ -58,7 +59,6 @@ int main() assert(!l.empty()); assert(l2.get_allocator() == other_allocator<bool>(4)); } -#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{}); std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{}); @@ -72,6 +72,4 @@ int main() assert(l.empty()); assert(l2.get_allocator() == min_allocator<bool>()); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp index dd4bf9e01ea9..556b6e656439 100644 --- a/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp @@ -59,31 +59,40 @@ struct some_alloc3 int main() { +#if defined(_LIBCPP_VERSION) { typedef std::vector<bool> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::vector<bool, test_allocator<bool>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::vector<bool, other_allocator<bool>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION { - typedef std::vector<bool, some_alloc<bool>> C; #if TEST_STD_VER > 14 - LIBCPP_STATIC_ASSERT( std::is_nothrow_move_assignable<C>::value, ""); +#if defined(_LIBCPP_VERSION) + typedef std::vector<bool, some_alloc<bool>> C; + static_assert( std::is_nothrow_move_assignable<C>::value, ""); +#endif // _LIBCPP_VERSION #else + typedef std::vector<bool, some_alloc<bool>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); #endif } #if TEST_STD_VER > 14 +#if defined(_LIBCPP_VERSION) { // POCMA false, is_always_equal true typedef std::vector<bool, some_alloc2<bool>> C; - LIBCPP_STATIC_ASSERT( std::is_nothrow_move_assignable<C>::value, ""); + static_assert( std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION { // POCMA false, is_always_equal false typedef std::vector<bool, some_alloc3<bool>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); diff --git a/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp index 3305d95e1ab8..f104eb32e5f4 100644 --- a/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp @@ -31,24 +31,29 @@ struct some_alloc int main() { +#if defined(_LIBCPP_VERSION) { typedef std::vector<bool> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::vector<bool, test_allocator<bool>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::vector<bool, other_allocator<bool>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { - typedef std::vector<bool, some_alloc<bool>> C; // In C++17, move constructors for allocators are not allowed to throw #if TEST_STD_VER > 14 - LIBCPP_STATIC_ASSERT( std::is_nothrow_move_constructible<C>::value, ""); +#if defined(_LIBCPP_VERSION) + typedef std::vector<bool, some_alloc<bool>> C; + static_assert( std::is_nothrow_move_constructible<C>::value, ""); +#endif // _LIBCPP_VERSION #else + typedef std::vector<bool, some_alloc<bool>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); #endif } diff --git a/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp b/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp index 4b959cf00ad3..61874338d655 100644 --- a/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector& operator=(initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector<bool> d; d = {true, false, false, true}; @@ -28,7 +29,6 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> d; d = {true, false, false, true}; @@ -38,6 +38,4 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } 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 1b68eda2757b..d888af05f92f 100644 --- a/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp @@ -55,32 +55,39 @@ struct some_alloc2 int main() { +#if defined(_LIBCPP_VERSION) { typedef std::vector<bool> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::vector<bool, test_allocator<bool>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::vector<bool, other_allocator<bool>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { - typedef std::vector<bool, some_alloc<bool>> C; #if TEST_STD_VER >= 14 +#if defined(_LIBCPP_VERSION) // In c++14, if POCS is set, swapping the allocator is required not to throw - LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + typedef std::vector<bool, some_alloc<bool>> C; + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); +#endif // _LIBCPP_VERSION #else + typedef std::vector<bool, some_alloc<bool>> C; static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); #endif } #if TEST_STD_VER >= 14 +#if defined(_LIBCPP_VERSION) { typedef std::vector<bool, some_alloc2<bool>> C; // if the allocators are always equal, then the swap can be noexcept - LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION #endif } diff --git a/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp b/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp index 4f82792fa1fd..64104a40ec74 100644 --- a/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp +++ b/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp @@ -31,7 +31,8 @@ int main() typedef std::hash<T> H; static_assert((std::is_same<H::argument_type, T>::value), "" ); static_assert((std::is_same<H::result_type, std::size_t>::value), "" ); - + ASSERT_NOEXCEPT(H()(T())); + bool ba[] = {true, false, true, true, false}; T vb(std::begin(ba), std::end(ba)); H h; @@ -43,6 +44,7 @@ int main() typedef std::hash<T> H; static_assert((std::is_same<H::argument_type, T>::value), "" ); static_assert((std::is_same<H::result_type, std::size_t>::value), "" ); + ASSERT_NOEXCEPT(H()(T())); bool ba[] = {true, false, true, true, false}; T vb(std::begin(ba), std::end(ba)); H h; |