Home | History | Annotate | Download | only in deque.cons
      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, const allocator_type& a);
     13 
     14 #include <deque>
     15 #include <cassert>
     16 
     17 #include "min_allocator.h"
     18 
     19 template <class T, class Allocator>
     20 void
     21 test(unsigned n, const T& x, const Allocator& a)
     22 {
     23     typedef std::deque<T, Allocator> C;
     24     typedef typename C::const_iterator const_iterator;
     25     C d(n, x, a);
     26     assert(d.get_allocator() == a);
     27     assert(d.size() == n);
     28     assert(distance(d.begin(), d.end()) == d.size());
     29     for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
     30         assert(*i == x);
     31 }
     32 
     33 int main()
     34 {
     35     {
     36     std::allocator<int> a;
     37     test(0, 5, a);
     38     test(1, 10, a);
     39     test(10, 11, a);
     40     test(1023, -11, a);
     41     test(1024, 25, a);
     42     test(1025, 0, a);
     43     test(2047, 110, a);
     44     test(2048, -500, a);
     45     test(2049, 654, a);
     46     test(4095, 78, a);
     47     test(4096, 1165, a);
     48     test(4097, 157, a);
     49     }
     50 #if __cplusplus >= 201103L
     51     {
     52     min_allocator<int> a;
     53     test(0, 5, a);
     54     test(1, 10, a);
     55     test(10, 11, a);
     56     test(1023, -11, a);
     57     test(1024, 25, a);
     58     test(1025, 0, a);
     59     test(2047, 110, a);
     60     test(2048, -500, a);
     61     test(2049, 654, a);
     62     test(4095, 78, a);
     63     test(4096, 1165, a);
     64     test(4097, 157, a);
     65     }
     66 #endif
     67 }
     68