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> deque(InputIterator f, InputIterator l); 13 14#include <deque> 15#include <cassert> 16#include <cstddef> 17 18#include "test_allocator.h" 19#include "test_iterators.h" 20#include "min_allocator.h" 21 22template <class InputIterator> 23void 24test(InputIterator f, InputIterator l) 25{ 26 typedef typename std::iterator_traits<InputIterator>::value_type T; 27 typedef std::allocator<T> Allocator; 28 typedef std::deque<T, Allocator> C; 29 typedef typename C::const_iterator const_iterator; 30 C d(f, l); 31 assert(d.size() == static_cast<std::size_t>(std::distance(f, l))); 32 assert(static_cast<std::size_t>(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 37template <class Allocator, class InputIterator> 38void 39test(InputIterator f, InputIterator l) 40{ 41 typedef typename std::iterator_traits<InputIterator>::value_type T; 42 typedef std::deque<T, Allocator> C; 43 typedef typename C::const_iterator const_iterator; 44 C d(f, l); 45 assert(d.size() == static_cast<std::size_t>(std::distance(f, l))); 46 assert(static_cast<std::size_t>(distance(d.begin(), d.end())) == d.size()); 47 for (const_iterator i = d.begin(), e = d.end(); i != e; ++i, ++f) 48 assert(*i == *f); 49} 50 51int main() 52{ 53 int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45}; 54 int* an = ab + sizeof(ab)/sizeof(ab[0]); 55 test(input_iterator<const int*>(ab), input_iterator<const int*>(an)); 56 test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an)); 57 test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an)); 58 test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an)); 59 test<limited_allocator<int, 4096> >(ab, an); 60#if TEST_STD_VER >= 11 61 test<min_allocator<int> >(ab, an); 62#endif 63} 64