1bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//===----------------------------------------------------------------------===//
2bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//
3f5256e16dfc425c1d466f6308d4026d529ce9e0bHoward Hinnant//                     The LLVM Compiler Infrastructure
4bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//
5b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant// This file is dual licensed under the MIT and the University of Illinois Open
6b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant// Source Licenses. See LICENSE.TXT for details.
7bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//
8bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//===----------------------------------------------------------------------===//
9bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
10bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// <deque>
11bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
12bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// template <class InputIterator>
13bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//   deque(InputIterator f, InputIterator l, const allocator_type& a);
14bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
15bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant#include <deque>
16bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant#include <cassert>
17bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
1883e2c4d877fe2d7793868b1c6a5d9525a7c4d431Marshall Clow#include "test_iterators.h"
191b92188a82b01e76ac6e8ad5f997293c2a078adcMarshall Clow#include "test_allocator.h"
20061d0cc4db18d17bf01ed14c5db0be098205bd47Marshall Clow#include "min_allocator.h"
21bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
22bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnanttemplate <class InputIterator, class Allocator>
23bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnantvoid
24bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnanttest(InputIterator f, InputIterator l, const Allocator& a)
25bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant{
26bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    typedef typename std::iterator_traits<InputIterator>::value_type T;
27bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    typedef std::deque<T, Allocator> C;
28bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    typedef typename C::const_iterator const_iterator;
29bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    C d(f, l, a);
30bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert(d.get_allocator() == a);
31bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert(d.size() == std::distance(f, l));
32bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert(distance(d.begin(), d.end()) == d.size());
33bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    for (const_iterator i = d.begin(), e = d.end(); i != e; ++i, ++f)
34bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(*i == *f);
35bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant}
36bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
37bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnantint main()
38bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant{
39bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
40bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    int* an = ab + sizeof(ab)/sizeof(ab[0]);
41bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test(input_iterator<const int*>(ab), input_iterator<const int*>(an), test_allocator<int>(3));
42bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an), test_allocator<int>(4));
43bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an), test_allocator<int>(5));
44bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an), test_allocator<int>(6));
45fcd8db7133c56a5a627f3922ce4a180c12287dd9Howard Hinnant#if __cplusplus >= 201103L
46fcd8db7133c56a5a627f3922ce4a180c12287dd9Howard Hinnant    test(input_iterator<const int*>(ab), input_iterator<const int*>(an), min_allocator<int>());
47fcd8db7133c56a5a627f3922ce4a180c12287dd9Howard Hinnant    test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an), min_allocator<int>());
48fcd8db7133c56a5a627f3922ce4a180c12287dd9Howard Hinnant    test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an), min_allocator<int>());
49fcd8db7133c56a5a627f3922ce4a180c12287dd9Howard Hinnant    test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an), min_allocator<int>());
50fcd8db7133c56a5a627f3922ce4a180c12287dd9Howard Hinnant#endif
51bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant}
52