//===----------------------------------------------------------------------===// // // 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. // //===----------------------------------------------------------------------===// // // explicit deque(size_type n); #include #include #include #include "test_macros.h" #include "test_allocator.h" #include "DefaultOnly.h" #include "min_allocator.h" template void test2(unsigned n) { #if TEST_STD_VER > 11 typedef std::deque C; typedef typename C::const_iterator const_iterator; assert(DefaultOnly::count == 0); { C d(n, Allocator()); assert(static_cast(DefaultOnly::count) == n); assert(d.size() == n); assert(static_cast(distance(d.begin(), d.end())) == d.size()); for (const_iterator i = d.begin(), e = d.end(); i != e; ++i) assert(*i == T()); } assert(DefaultOnly::count == 0); #else ((void)n); #endif } template void test1(unsigned n) { typedef std::deque C; typedef typename C::const_iterator const_iterator; assert(DefaultOnly::count == 0); { C d(n); assert(static_cast(DefaultOnly::count) == n); assert(d.size() == n); assert(static_cast(distance(d.begin(), d.end())) == d.size()); #if TEST_STD_VER >= 11 for (const_iterator i = d.begin(), e = d.end(); i != e; ++i) assert(*i == T()); #endif } assert(DefaultOnly::count == 0); } template void test3(unsigned n, Allocator const &alloc = Allocator()) { #if TEST_STD_VER > 11 typedef std::deque C; { C d(n, alloc); assert(d.size() == n); assert(d.get_allocator() == alloc); } #else ((void)n); ((void)alloc); #endif } template void test(unsigned n) { test1 ( n ); test2 ( n ); } int main() { test >(0); test >(1); test >(10); test >(1023); test >(1024); test >(1025); test >(2047); test >(2048); test >(2049); test >(4095); test >(4096); test >(4097); LIBCPP_ONLY(test1 >(4095)); #if TEST_STD_VER >= 11 test >(4095); #endif #if TEST_STD_VER > 11 test3> (1023); test3>(1); test3> (3); #endif }