]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/std/ranges/iota/difference_type.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / std / ranges / iota / difference_type.cc
CommitLineData
a945c346 1// Copyright (C) 2020-2024 Free Software Foundation, Inc.
e6c76f0d
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
d4ac20b0 18// { dg-do run { target c++20 } }
e6c76f0d
PP
19
20#include <ranges>
9af65c2b 21#include <limits>
e6c76f0d
PP
22#include <testsuite_hooks.h>
23
24void
25test01()
26{
27 using I = unsigned long long;
28 auto imax = std::numeric_limits<I>::max();
29 std::ranges::iota_view<I, I> i(0, imax);
30 auto begin = i.begin();
31 static_assert( std::input_or_output_iterator<decltype(begin)> );
32 auto size = std::ranges::end(i) - std::ranges::begin(i);
33 VERIFY( size > 0 );
34 VERIFY( size == imax );
35}
36
37void
38test02()
39{
40#if !defined(__STRICT_ANSI__) && __SIZEOF_INT128__
41 using I = unsigned __int128;
42 auto imax = std::numeric_limits<I>::max();
43 std::ranges::iota_view<I, I> i(0, imax);
44 auto begin = i.begin();
45 static_assert( std::input_or_output_iterator<decltype(begin)> );
46 auto size = std::ranges::end(i) - std::ranges::begin(i);
47 VERIFY( size > 0 );
48 VERIFY( size == imax );
49#endif
50}
51
52int
53main()
54{
55 test01();
56 test02();
57}