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