]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/unique_ptr/comparison/compare.cc
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++11 } }
21 #include <testsuite_hooks.h>
26 std::unique_ptr
<int> p0
, p00
;
28 VERIFY( !(p0
< p00
) );
29 VERIFY( !(p0
> p00
) );
33 std::unique_ptr
<int> p1(new int(1));
40 std::unique_ptr
<const int> p2(new int(1));
43 VERIFY( (p1
< p2
) || (p1
> p2
) );
44 VERIFY( (p1
<= p2
) || (p1
>= p2
) );
49 VERIFY( !(p1
<= p0
) );
56 std::unique_ptr
<int> p0
;
57 VERIFY( p0
== nullptr );
58 VERIFY( !(p0
< nullptr) );
59 VERIFY( !(p0
> nullptr) );
60 VERIFY( p0
<= nullptr );
61 VERIFY( p0
>= nullptr );
63 VERIFY( nullptr == p0
);
64 VERIFY( !(nullptr < p0
) );
65 VERIFY( !(nullptr > p0
) );
66 VERIFY( nullptr <= p0
);
67 VERIFY( nullptr >= p0
);
69 std::unique_ptr
<int> p1(new int(1));
70 VERIFY( p1
!= nullptr );
71 VERIFY( !(p1
< nullptr) );
72 VERIFY( p1
> nullptr );
73 VERIFY( !(p1
<= nullptr) );
74 VERIFY( p1
>= nullptr );
76 VERIFY( nullptr != p1
);
77 VERIFY( nullptr < p1
);
78 VERIFY( !(nullptr > p1
) );
79 VERIFY( nullptr <= p1
);
80 VERIFY( !(nullptr >= p1
) );