[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / containers / sequences / deque / deque.cons / size.pass.cpp
blobde1a9843a478ec3215cfcd15c730accc6458b62d
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 // <deque>
11 // explicit deque(size_type n);
13 #include "asan_testing.h"
14 #include <deque>
15 #include <cassert>
16 #include <cstddef>
18 #include "test_macros.h"
19 #include "test_allocator.h"
20 #include "DefaultOnly.h"
21 #include "min_allocator.h"
23 template <class T, class Allocator>
24 void
25 test2(unsigned n)
27 #if TEST_STD_VER > 11
28 typedef std::deque<T, Allocator> C;
29 typedef typename C::const_iterator const_iterator;
30 assert(DefaultOnly::count == 0);
32 C d(n, Allocator());
33 assert(static_cast<unsigned>(DefaultOnly::count) == n);
34 assert(d.size() == n);
35 assert(static_cast<std::size_t>(std::distance(d.begin(), d.end())) == d.size());
36 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(d));
37 for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
38 assert(*i == T());
40 assert(DefaultOnly::count == 0);
41 #else
42 ((void)n);
43 #endif
46 template <class T, class Allocator>
47 void
48 test1(unsigned n)
50 typedef std::deque<T, Allocator> C;
51 typedef typename C::const_iterator const_iterator;
52 assert(DefaultOnly::count == 0);
54 C d(n);
55 assert(static_cast<unsigned>(DefaultOnly::count) == n);
56 assert(d.size() == n);
57 assert(static_cast<std::size_t>(std::distance(d.begin(), d.end())) == d.size());
58 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(d));
59 #if TEST_STD_VER >= 11
60 for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
61 assert(*i == T());
62 #endif
64 assert(DefaultOnly::count == 0);
67 template <class T, class Allocator>
68 void
69 test3(unsigned n, Allocator const &alloc = Allocator())
71 #if TEST_STD_VER > 11
72 typedef std::deque<T, Allocator> C;
74 C d(n, alloc);
75 assert(d.size() == n);
76 assert(d.get_allocator() == alloc);
77 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(d));
79 #else
80 ((void)n);
81 ((void)alloc);
82 #endif
85 template <class T, class Allocator>
86 void
87 test(unsigned n)
89 test1<T, Allocator> ( n );
90 test2<T, Allocator> ( n );
93 int main(int, char**)
95 test<DefaultOnly, std::allocator<DefaultOnly> >(0);
96 test<DefaultOnly, std::allocator<DefaultOnly> >(1);
97 test<DefaultOnly, std::allocator<DefaultOnly> >(10);
98 test<DefaultOnly, std::allocator<DefaultOnly> >(1023);
99 test<DefaultOnly, std::allocator<DefaultOnly> >(1024);
100 test<DefaultOnly, std::allocator<DefaultOnly> >(1025);
101 test<DefaultOnly, std::allocator<DefaultOnly> >(2047);
102 test<DefaultOnly, std::allocator<DefaultOnly> >(2048);
103 test<DefaultOnly, std::allocator<DefaultOnly> >(2049);
104 test<DefaultOnly, std::allocator<DefaultOnly> >(4095);
105 test<DefaultOnly, std::allocator<DefaultOnly> >(4096);
106 test<DefaultOnly, std::allocator<DefaultOnly> >(4097);
108 LIBCPP_ONLY(test1<DefaultOnly, limited_allocator<DefaultOnly, 4096> >(4095));
110 #if TEST_STD_VER >= 11
111 test<DefaultOnly, min_allocator<DefaultOnly> >(4095);
112 #endif
114 #if TEST_STD_VER > 11
115 test3<DefaultOnly, std::allocator<DefaultOnly>> (1023);
116 test3<int, std::allocator<int>>(1);
117 test3<int, min_allocator<int>> (3);
118 #endif
121 return 0;