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 // <algorithm>
11 
12 // template<InputIterator Iter1, InputIterator Iter2>
13 //   requires HasEqualTo<Iter1::value_type, Iter2::value_type>
14 //   bool
15 //   equal(Iter1 first1, Iter1 last1, Iter2 first2);
16 
17 #include <algorithm>
18 #include <cassert>
19 
20 #include "test_iterators.h"
21 
22 #if _LIBCPP_STD_VER > 11
23 #define HAS_FOUR_ITERATOR_VERSION
24 #endif
25 
main()26 int main()
27 {
28     int ia[] = {0, 1, 2, 3, 4, 5};
29     const unsigned s = sizeof(ia)/sizeof(ia[0]);
30     int ib[s] = {0, 1, 2, 5, 4, 5};
31     assert(std::equal(input_iterator<const int*>(ia),
32                       input_iterator<const int*>(ia+s),
33                       input_iterator<const int*>(ia)));
34 #ifdef HAS_FOUR_ITERATOR_VERSION
35     assert(std::equal(input_iterator<const int*>(ia),
36                       input_iterator<const int*>(ia+s),
37                       input_iterator<const int*>(ia),
38                       input_iterator<const int*>(ia+s)));
39     assert(std::equal(random_access_iterator<const int*>(ia),
40                       random_access_iterator<const int*>(ia+s),
41                       random_access_iterator<const int*>(ia),
42                       random_access_iterator<const int*>(ia+s)));
43 #endif
44     assert(!std::equal(input_iterator<const int*>(ia),
45                        input_iterator<const int*>(ia+s),
46                        input_iterator<const int*>(ib)));
47 #ifdef HAS_FOUR_ITERATOR_VERSION
48     assert(!std::equal(input_iterator<const int*>(ia),
49                        input_iterator<const int*>(ia+s),
50                        input_iterator<const int*>(ib),
51                        input_iterator<const int*>(ib+s)));
52     assert(!std::equal(random_access_iterator<const int*>(ia),
53                        random_access_iterator<const int*>(ia+s),
54                        random_access_iterator<const int*>(ib),
55                        random_access_iterator<const int*>(ib+s)));
56     assert(!std::equal(input_iterator<const int*>(ia),
57                        input_iterator<const int*>(ia+s),
58                        input_iterator<const int*>(ia),
59                        input_iterator<const int*>(ia+s-1)));
60     assert(!std::equal(random_access_iterator<const int*>(ia),
61                        random_access_iterator<const int*>(ia+s),
62                        random_access_iterator<const int*>(ia),
63                        random_access_iterator<const int*>(ia+s-1)));
64 
65 #endif
66 }
67