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 // template <class InputIterator>
13 //   deque(InputIterator f, InputIterator l, const allocator_type& a);
14 
15 #include <deque>
16 #include <cassert>
17 
18 #include "test_iterators.h"
19 #include "../../../test_allocator.h"
20 #include "../../../min_allocator.h"
21 
22 template <class InputIterator, class Allocator>
23 void
24 test(InputIterator f, InputIterator l, const Allocator& a)
25 {
26     typedef typename std::iterator_traits<InputIterator>::value_type T;
27     typedef std::deque<T, Allocator> C;
28     typedef typename C::const_iterator const_iterator;
29     C d(f, l, a);
30     assert(d.get_allocator() == a);
31     assert(d.size() == std::distance(f, l));
32     assert(distance(d.begin(), d.end()) == d.size());
33     for (const_iterator i = d.begin(), e = d.end(); i != e; ++i, ++f)
34         assert(*i == *f);
35 }
36 
37 int main()
38 {
39     int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
40     int* an = ab + sizeof(ab)/sizeof(ab[0]);
41     test(input_iterator<const int*>(ab), input_iterator<const int*>(an), test_allocator<int>(3));
42     test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an), test_allocator<int>(4));
43     test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an), test_allocator<int>(5));
44     test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an), test_allocator<int>(6));
45 #if __cplusplus >= 201103L
46     test(input_iterator<const int*>(ab), input_iterator<const int*>(an), min_allocator<int>());
47     test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an), min_allocator<int>());
48     test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an), min_allocator<int>());
49     test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an), min_allocator<int>());
50 #endif
51 }
52