]>
Commit | Line | Data |
---|---|---|
83ffe9cd | 1 | // Copyright (C) 2020-2023 Free Software Foundation, Inc. |
f5fa62ed JW |
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 } } | |
7cc9022f | 20 | // { dg-require-effective-target hosted } |
f5fa62ed JW |
21 | |
22 | #include <memory> | |
23 | #include <testsuite_hooks.h> | |
24 | ||
25 | void | |
26 | test01() | |
27 | { | |
28 | std::shared_ptr<int> p0, p00; | |
29 | VERIFY( p0 == p00 ); | |
30 | VERIFY( !(p0 < p00) ); | |
31 | VERIFY( !(p0 > p00) ); | |
32 | VERIFY( p0 <= p00 ); | |
33 | VERIFY( p0 >= p00 ); | |
34 | VERIFY( std::is_eq(p0 <=> p00) ); | |
35 | ||
36 | std::shared_ptr<int> p1(new int(1)); | |
37 | VERIFY( p1 == p1 ); | |
38 | VERIFY( !(p1 < p1) ); | |
39 | VERIFY( !(p1 > p1) ); | |
40 | VERIFY( p1 <= p1 ); | |
41 | VERIFY( p1 >= p1 ); | |
42 | VERIFY( std::is_eq(p1 <=> p1) ); | |
43 | ||
44 | std::shared_ptr<int> p11 = p1; | |
45 | VERIFY( p11 == p1 ); | |
46 | VERIFY( !(p11 < p1) ); | |
47 | VERIFY( !(p11 > p1) ); | |
48 | VERIFY( p11 <= p1 ); | |
49 | VERIFY( p11 >= p1 ); | |
50 | VERIFY( std::is_eq(p11 <=> p1) ); | |
51 | ||
52 | std::shared_ptr<const int> p2(new int(1)); | |
53 | VERIFY( p1 >= p1 ); | |
54 | VERIFY( p1 != p2 ); | |
55 | VERIFY( (p1 < p2) || (p1 > p2) ); | |
56 | VERIFY( (p1 <= p2) || (p1 >= p2) ); | |
57 | VERIFY( std::is_neq(p1 <=> p2) ); | |
58 | ||
59 | VERIFY( p1 != p0 ); | |
60 | VERIFY( !(p1 < p0) ); | |
61 | VERIFY( p1 > p0 ); | |
62 | VERIFY( !(p1 <= p0) ); | |
63 | VERIFY( p1 >= p0 ); | |
64 | VERIFY( std::is_gt(p1 <=> p0) ); | |
65 | VERIFY( std::is_lt(p0 <=> p1) ); | |
66 | } | |
67 | ||
68 | void | |
69 | test02() | |
70 | { | |
71 | std::shared_ptr<int> p0; | |
72 | VERIFY( p0 == nullptr ); | |
73 | VERIFY( !(p0 < nullptr) ); | |
74 | VERIFY( !(p0 > nullptr) ); | |
75 | VERIFY( p0 <= nullptr ); | |
76 | VERIFY( p0 >= nullptr ); | |
77 | VERIFY( std::is_eq(p0 <=> nullptr) ); | |
78 | ||
79 | VERIFY( nullptr == p0 ); | |
80 | VERIFY( !(nullptr < p0) ); | |
81 | VERIFY( !(nullptr > p0) ); | |
82 | VERIFY( nullptr <= p0 ); | |
83 | VERIFY( nullptr >= p0 ); | |
84 | VERIFY( std::is_eq(nullptr <=> p0) ); | |
85 | ||
86 | std::shared_ptr<int> p1(new int(1)); | |
87 | VERIFY( p1 != nullptr ); | |
88 | VERIFY( !(p1 < nullptr) ); | |
89 | VERIFY( p1 > nullptr ); | |
90 | VERIFY( !(p1 <= nullptr) ); | |
91 | VERIFY( p1 >= nullptr ); | |
92 | VERIFY( std::is_gt(p1 <=> nullptr) ); | |
93 | ||
94 | VERIFY( nullptr != p1 ); | |
95 | VERIFY( nullptr < p1 ); | |
96 | VERIFY( !(nullptr > p1) ); | |
97 | VERIFY( nullptr <= p1 ); | |
98 | VERIFY( !(nullptr >= p1) ); | |
99 | VERIFY( std::is_lt(nullptr <=> p1) ); | |
100 | } | |
101 | ||
102 | int | |
103 | main() | |
104 | { | |
105 | test01(); | |
106 | test02(); | |
107 | } |