[TableGen][SystemZ] Correctly check the range of a leaf immediate (#119931)
[llvm-project.git] / libcxx / test / std / containers / sequences / vector.bool / construct_iter_iter.pass.cpp
blob2f520d5abbf3e360f29747da51ce5426cd96a0c5
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 // <vector>
10 // vector<bool>
12 // template <class InputIter> vector(InputIter first, InputIter last);
14 #include <vector>
15 #include <cassert>
16 #include <cstddef>
18 #include "test_macros.h"
19 #include "test_iterators.h"
20 #include "min_allocator.h"
22 template <class C, class Iterator>
23 TEST_CONSTEXPR_CXX20 void test(Iterator first, Iterator last)
25 C c(first, last);
26 LIBCPP_ASSERT(c.__invariants());
27 assert(c.size() == static_cast<std::size_t>(std::distance(first, last)));
28 for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
29 assert(*i == *first);
32 TEST_CONSTEXPR_CXX20 bool tests()
34 bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
35 bool* an = a + sizeof(a)/sizeof(a[0]);
36 test<std::vector<bool> >(cpp17_input_iterator<const bool*>(a), cpp17_input_iterator<const bool*>(an));
37 test<std::vector<bool> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an));
38 test<std::vector<bool> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an));
39 test<std::vector<bool> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an));
40 test<std::vector<bool> >(a, an);
41 #if TEST_STD_VER >= 11
42 test<std::vector<bool, min_allocator<bool>> >(cpp17_input_iterator<const bool*>(a), cpp17_input_iterator<const bool*>(an));
43 test<std::vector<bool, min_allocator<bool>> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an));
44 test<std::vector<bool, min_allocator<bool>> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an));
45 test<std::vector<bool, min_allocator<bool>> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an));
46 test<std::vector<bool, min_allocator<bool>> >(a, an);
47 #endif
49 return true;
52 int main(int, char**)
54 tests();
55 #if TEST_STD_VER > 17
56 static_assert(tests());
57 #endif
58 return 0;