1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is dual licensed under the MIT and the University of Illinois Open 6// Source Licenses. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <vector> 11// vector<bool> 12 13// explicit vector(size_type n); 14 15#include <vector> 16#include <cassert> 17 18#include "test_macros.h" 19#include "min_allocator.h" 20#include "test_allocator.h" 21 22template <class C> 23void 24test2(typename C::size_type n, 25 typename C::allocator_type const& a = typename C::allocator_type ()) 26{ 27#if TEST_STD_VER >= 14 28 C c(n, a); 29 LIBCPP_ASSERT(c.__invariants()); 30 assert(c.size() == n); 31 assert(c.get_allocator() == a); 32 for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i) 33 assert(*i == typename C::value_type()); 34#else 35 ((void)n); 36 ((void)a); 37#endif 38} 39 40template <class C> 41void 42test1(typename C::size_type n) 43{ 44 C c(n); 45 LIBCPP_ASSERT(c.__invariants()); 46 assert(c.size() == n); 47 assert(c.get_allocator() == typename C::allocator_type()); 48 for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i) 49 assert(*i == typename C::value_type()); 50} 51 52template <class C> 53void 54test(typename C::size_type n) 55{ 56 test1<C> ( n ); 57 test2<C> ( n ); 58} 59 60int main() 61{ 62 test<std::vector<bool> >(50); 63#if TEST_STD_VER >= 11 64 test<std::vector<bool, min_allocator<bool>> >(50); 65 test2<std::vector<bool, test_allocator<bool>> >( 100, test_allocator<bool>(23)); 66#endif 67} 68