15a83710eSEric Fiselier //===----------------------------------------------------------------------===//
25a83710eSEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65a83710eSEric Fiselier //
75a83710eSEric Fiselier //===----------------------------------------------------------------------===//
85a83710eSEric Fiselier 
95a83710eSEric Fiselier // <vector>
105a83710eSEric Fiselier // vector<bool>
115a83710eSEric Fiselier 
125a83710eSEric Fiselier // template <class InputIter> vector(InputIter first, InputIter last);
135a83710eSEric Fiselier 
145a83710eSEric Fiselier #include <vector>
155a83710eSEric Fiselier #include <cassert>
16fbfb2ab6SStephan T. Lavavej #include <cstddef>
175a83710eSEric Fiselier 
181f4231f8SEric Fiselier #include "test_macros.h"
195a83710eSEric Fiselier #include "test_iterators.h"
205a83710eSEric Fiselier #include "min_allocator.h"
215a83710eSEric Fiselier 
225a83710eSEric Fiselier template <class C, class Iterator>
test(Iterator first,Iterator last)23*c74059c5SNikolas Klauser TEST_CONSTEXPR_CXX20 void test(Iterator first, Iterator last)
245a83710eSEric Fiselier {
255a83710eSEric Fiselier     C c(first, last);
261f4231f8SEric Fiselier     LIBCPP_ASSERT(c.__invariants());
27fbfb2ab6SStephan T. Lavavej     assert(c.size() == static_cast<std::size_t>(std::distance(first, last)));
285a83710eSEric Fiselier     for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
295a83710eSEric Fiselier         assert(*i == *first);
305a83710eSEric Fiselier }
315a83710eSEric Fiselier 
tests()32*c74059c5SNikolas Klauser TEST_CONSTEXPR_CXX20 bool tests()
335a83710eSEric Fiselier {
345a83710eSEric Fiselier     bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
355a83710eSEric Fiselier     bool* an = a + sizeof(a)/sizeof(a[0]);
36773ae441SChristopher Di Bella     test<std::vector<bool> >(cpp17_input_iterator<const bool*>(a), cpp17_input_iterator<const bool*>(an));
375a83710eSEric Fiselier     test<std::vector<bool> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an));
385a83710eSEric Fiselier     test<std::vector<bool> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an));
395a83710eSEric Fiselier     test<std::vector<bool> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an));
405a83710eSEric Fiselier     test<std::vector<bool> >(a, an);
411f4231f8SEric Fiselier #if TEST_STD_VER >= 11
42773ae441SChristopher Di Bella     test<std::vector<bool, min_allocator<bool>> >(cpp17_input_iterator<const bool*>(a), cpp17_input_iterator<const bool*>(an));
435a83710eSEric Fiselier     test<std::vector<bool, min_allocator<bool>> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an));
445a83710eSEric Fiselier     test<std::vector<bool, min_allocator<bool>> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an));
455a83710eSEric Fiselier     test<std::vector<bool, min_allocator<bool>> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an));
465a83710eSEric Fiselier     test<std::vector<bool, min_allocator<bool>> >(a, an);
475a83710eSEric Fiselier #endif
482df59c50SJF Bastien 
49*c74059c5SNikolas Klauser     return true;
50*c74059c5SNikolas Klauser }
51*c74059c5SNikolas Klauser 
main(int,char **)52*c74059c5SNikolas Klauser int main(int, char**)
53*c74059c5SNikolas Klauser {
54*c74059c5SNikolas Klauser     tests();
55*c74059c5SNikolas Klauser #if TEST_STD_VER > 17
56*c74059c5SNikolas Klauser     static_assert(tests());
57*c74059c5SNikolas Klauser #endif
582df59c50SJF Bastien     return 0;
595a83710eSEric Fiselier }
60