libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

size_value.pass.cpp (1630B)


      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 // <deque>
     11 
     12 // deque(size_type n, const value_type& v);
     13 
     14 #include <deque>
     15 #include <cassert>
     16 #include <cstddef>
     17 
     18 #include "test_allocator.h"
     19 #include "min_allocator.h"
     20 
     21 template <class T, class Allocator>
     22 void
     23 test(unsigned n, const T& x)
     24 {
     25     typedef std::deque<T, Allocator> C;
     26     typedef typename C::const_iterator const_iterator;
     27     C d(n, x);
     28     assert(d.size() == n);
     29     assert(static_cast<std::size_t>(distance(d.begin(), d.end())) == d.size());
     30     for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
     31         assert(*i == x);
     32 }
     33 
     34 int main()
     35 {
     36     test<int, std::allocator<int> >(0, 5);
     37     test<int, std::allocator<int> >(1, 10);
     38     test<int, std::allocator<int> >(10, 11);
     39     test<int, std::allocator<int> >(1023, -11);
     40     test<int, std::allocator<int> >(1024, 25);
     41     test<int, std::allocator<int> >(1025, 0);
     42     test<int, std::allocator<int> >(2047, 110);
     43     test<int, std::allocator<int> >(2048, -500);
     44     test<int, std::allocator<int> >(2049, 654);
     45     test<int, std::allocator<int> >(4095, 78);
     46     test<int, std::allocator<int> >(4096, 1165);
     47     test<int, std::allocator<int> >(4097, 157);
     48     LIBCPP_ONLY(test<int, limited_allocator<int, 4096> >(4095, 90));
     49 #if TEST_STD_VER >= 11
     50     test<int, min_allocator<int> >(4095, 90);
     51 #endif
     52 }