Debian Codegraph @

libcxx/test/libcxx-03/iterators/bounded_iter/comparison.pass.cpp

raw
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // template <class _Iterator>
10 // struct __bounded_iter;
11 //
12 // Comparison operators
13
14 #include <concepts>
15 #include <__cxx03/__iterator/bounded_iter.h>
16
17 #include "test_iterators.h"
18 #include "test_macros.h"
19
20 template <class Iter>
21 TEST_CONSTEXPR_CXX14 bool tests() {
22 int array[] = {0, 1, 2, 3, 4};
23 int* b = array + 0;
24 int* e = array + 5;
25 std::__bounded_iter<Iter> const iter1 = std::__make_bounded_iter(Iter(b), Iter(b), Iter(e));
26 std::__bounded_iter<Iter> const iter2 = std::__make_bounded_iter(Iter(e), Iter(b), Iter(e));
27
28 // operator==
29 {
30 assert(iter1 == iter1);
31 assert(!(iter1 == iter2));
32 }
33 // operator!=
34 {
35 assert(iter1 != iter2);
36 assert(!(iter1 != iter1));
37 }
38 // operator<
39 {
40 assert(iter1 < iter2);
41 assert(!(iter2 < iter1));
42 assert(!(iter1 < iter1));
43 }
44 // operator>
45 {
46 assert(iter2 > iter1);
47 assert(!(iter1 > iter2));
48 assert(!(iter1 > iter1));
49 }
50 // operator<=
51 {
52 assert(iter1 <= iter2);
53 assert(!(iter2 <= iter1));
54 assert(iter1 <= iter1);
55 }
56 // operator>=
57 {
58 assert(iter2 >= iter1);
59 assert(!(iter1 >= iter2));
60 assert(iter1 >= iter1);
61 }
62
63 return true;
64 }
65
66 int main(int, char**) {
67 tests<int*>();
68
69 return 0;
70 }