[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / algorithms / alg.modifying.operations / alg.reverse / reverse.pass.cpp
blobe7930a57acf0f9b5ebba211ee9ee1caa268c96b2
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 //===----------------------------------------------------------------------===//
9 // <algorithm>
11 // template<BidirectionalIterator Iter>
12 // requires HasSwap<Iter::reference, Iter::reference>
13 // void
14 // reverse(Iter first, Iter last);
16 #include <algorithm>
17 #include <cassert>
19 #include "test_macros.h"
20 #include "test_iterators.h"
22 template <class Iter>
23 void
24 test()
26 int ia[] = {0};
27 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
28 std::reverse(Iter(ia), Iter(ia));
29 assert(ia[0] == 0);
30 std::reverse(Iter(ia), Iter(ia+sa));
31 assert(ia[0] == 0);
33 int ib[] = {0, 1};
34 const unsigned sb = sizeof(ib)/sizeof(ib[0]);
35 std::reverse(Iter(ib), Iter(ib+sb));
36 assert(ib[0] == 1);
37 assert(ib[1] == 0);
39 int ic[] = {0, 1, 2};
40 const unsigned sc = sizeof(ic)/sizeof(ic[0]);
41 std::reverse(Iter(ic), Iter(ic+sc));
42 assert(ic[0] == 2);
43 assert(ic[1] == 1);
44 assert(ic[2] == 0);
46 int id[] = {0, 1, 2, 3};
47 const unsigned sd = sizeof(id)/sizeof(id[0]);
48 std::reverse(Iter(id), Iter(id+sd));
49 assert(id[0] == 3);
50 assert(id[1] == 2);
51 assert(id[2] == 1);
52 assert(id[3] == 0);
55 int main(int, char**)
57 test<bidirectional_iterator<int*> >();
58 test<random_access_iterator<int*> >();
59 test<int*>();
61 return 0;