libstdc++: Remove dg-options "-std=gnu++20" from 20_utils tests
[official-gcc.git] / libstdc++-v3 / testsuite / 20_util / unique_ptr / comparison / compare_c++20.cc
blobe0d95040eb013fda518d9ccb9a4f31cacc84bc8d
1 // Copyright (C) 2020-2023 Free Software Foundation, Inc.
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.
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.
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/>.
18 // { dg-do run { target c++20 } }
20 #include <memory>
21 #include <testsuite_hooks.h>
23 void
24 test01()
26 std::unique_ptr<int> p0, p00;
27 VERIFY( p0 == p00 );
28 VERIFY( !(p0 < p00) );
29 VERIFY( !(p0 > p00) );
30 VERIFY( p0 <= p00 );
31 VERIFY( p0 >= p00 );
32 VERIFY( std::is_eq(p0 <=> p00) );
34 std::unique_ptr<int> p1(new int(1));
35 VERIFY( p1 == p1 );
36 VERIFY( !(p1 < p1) );
37 VERIFY( !(p1 > p1) );
38 VERIFY( p1 <= p1 );
39 VERIFY( p1 >= p1 );
40 VERIFY( std::is_eq(p1 <=> p1) );
42 std::unique_ptr<const int> p2(new int(1));
43 VERIFY( p1 >= p1 );
44 VERIFY( p1 != p2 );
45 VERIFY( (p1 < p2) || (p1 > p2) );
46 VERIFY( (p1 <= p2) || (p1 >= p2) );
47 VERIFY( std::is_neq(p1 <=> p2) );
49 VERIFY( p1 != p0 );
50 VERIFY( !(p1 < p0) );
51 VERIFY( p1 > p0 );
52 VERIFY( !(p1 <= p0) );
53 VERIFY( p1 >= p0 );
54 VERIFY( std::is_gt(p1 <=> p0) );
55 VERIFY( std::is_lt(p0 <=> p1) );
58 void
59 test02()
61 std::unique_ptr<int> p0;
62 VERIFY( p0 == nullptr );
63 VERIFY( !(p0 < nullptr) );
64 VERIFY( !(p0 > nullptr) );
65 VERIFY( p0 <= nullptr );
66 VERIFY( p0 >= nullptr );
67 VERIFY( std::is_eq(p0 <=> nullptr) );
69 VERIFY( nullptr == p0 );
70 VERIFY( !(nullptr < p0) );
71 VERIFY( !(nullptr > p0) );
72 VERIFY( nullptr <= p0 );
73 VERIFY( nullptr >= p0 );
74 VERIFY( std::is_eq(nullptr <=> p0) );
76 std::unique_ptr<int> p1(new int(1));
77 VERIFY( p1 != nullptr );
78 VERIFY( !(p1 < nullptr) );
79 VERIFY( p1 > nullptr );
80 VERIFY( !(p1 <= nullptr) );
81 VERIFY( p1 >= nullptr );
82 VERIFY( std::is_gt(p1 <=> nullptr) );
84 VERIFY( nullptr != p1 );
85 VERIFY( nullptr < p1 );
86 VERIFY( !(nullptr > p1) );
87 VERIFY( nullptr <= p1 );
88 VERIFY( !(nullptr >= p1) );
89 VERIFY( std::is_lt(nullptr <=> p1) );
92 int
93 main()
95 test01();
96 test02();