]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill_n/94017.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / specialized_algorithms / uninitialized_fill_n / 94017.cc
CommitLineData
83ffe9cd 1// Copyright (C) 2020-2023 Free Software Foundation, Inc.
712b182a
PP
2//
3// This file is part of the GNU ISO C++ Library. This library is free
4// software; you can redistribute it and/or modify it under the
5// terms of the GNU General Public License as published by the
6// Free Software Foundation; either version 3, or (at your option)
7// any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License along
15// with this library; see the file COPYING3. If not see
16// <http://www.gnu.org/licenses/>.
17
18// { dg-options "-std=gnu++2a" }
19// { dg-do run { target c++2a } }
20
21#include <algorithm>
22#include <memory>
23#include <testsuite_hooks.h>
24#include <testsuite_iterators.h>
25
26using __gnu_test::test_output_range;
27
28namespace ranges = std::ranges;
29
30template<typename Out, auto value>
31void
32test01()
33{
34 {
35 Out x[5];
36 ranges::uninitialized_fill_n(x, 5, value);
37 VERIFY( ranges::count(x, static_cast<Out>(value)) == ranges::size(x) );
38 }
39
40 {
41 Out x[5];
42 test_output_range<Out> rx(x);
43 ranges::uninitialized_fill_n(x, 5, value);
44 VERIFY( ranges::count(x, static_cast<Out>(value)) == ranges::size(x) );
45 }
46}
47
48int
49main()
50{
51 test01<char, 'a'>();
52 test01<char, 100>();
53 test01<char, 150>();
54 test01<char, 300>();
55 test01<char, 1000>();
56 test01<char, -10000L>();
57
58 test01<signed char, 'a'>();
59 test01<signed char, 100>();
60 test01<signed char, 150>();
61 test01<signed char, 300>();
62
63 test01<unsigned char, 'a'>();
64 test01<unsigned char, 100>();
65 test01<unsigned char, 150>();
66 test01<unsigned char, 300>();
67
68 test01<int, 'a'>();
69 test01<int, u8'a'>();
70 test01<int, (signed char)'a'>();
71 test01<int, (unsigned char)'a'>();
72
73 test01<volatile int, 'a'>();
74 test01<volatile int, 'a'>();
75 test01<volatile int, 500>();
76 test01<volatile char, 500>();
77}