1 // Copyright (C) 2020-2024 Free Software Foundation, Inc.
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)
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 } }
19 // { dg-require-effective-target hosted }
22 #include <testsuite_hooks.h>
27 std::shared_ptr
<int> p0
, p00
;
29 VERIFY( !(p0
< p00
) );
30 VERIFY( !(p0
> p00
) );
33 VERIFY( std::is_eq(p0
<=> p00
) );
35 std::shared_ptr
<int> p1(new int(1));
41 VERIFY( std::is_eq(p1
<=> p1
) );
43 std::shared_ptr
<int> p11
= p1
;
45 VERIFY( !(p11
< p1
) );
46 VERIFY( !(p11
> p1
) );
49 VERIFY( std::is_eq(p11
<=> p1
) );
51 std::shared_ptr
<const int> p2(new int(1));
54 VERIFY( (p1
< p2
) || (p1
> p2
) );
55 VERIFY( (p1
<= p2
) || (p1
>= p2
) );
56 VERIFY( std::is_neq(p1
<=> p2
) );
61 VERIFY( !(p1
<= p0
) );
63 VERIFY( std::is_gt(p1
<=> p0
) );
64 VERIFY( std::is_lt(p0
<=> p1
) );
70 std::shared_ptr
<int> p0
;
71 VERIFY( p0
== nullptr );
72 VERIFY( !(p0
< nullptr) );
73 VERIFY( !(p0
> nullptr) );
74 VERIFY( p0
<= nullptr );
75 VERIFY( p0
>= nullptr );
76 VERIFY( std::is_eq(p0
<=> nullptr) );
78 VERIFY( nullptr == p0
);
79 VERIFY( !(nullptr < p0
) );
80 VERIFY( !(nullptr > p0
) );
81 VERIFY( nullptr <= p0
);
82 VERIFY( nullptr >= p0
);
83 VERIFY( std::is_eq(nullptr <=> p0
) );
85 std::shared_ptr
<int> p1(new int(1));
86 VERIFY( p1
!= nullptr );
87 VERIFY( !(p1
< nullptr) );
88 VERIFY( p1
> nullptr );
89 VERIFY( !(p1
<= nullptr) );
90 VERIFY( p1
>= nullptr );
91 VERIFY( std::is_gt(p1
<=> nullptr) );
93 VERIFY( nullptr != p1
);
94 VERIFY( nullptr < p1
);
95 VERIFY( !(nullptr > p1
) );
96 VERIFY( nullptr <= p1
);
97 VERIFY( !(nullptr >= p1
) );
98 VERIFY( std::is_lt(nullptr <=> p1
) );