]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/integer_comparisons/not_equal.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / integer_comparisons / not_equal.cc
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.
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 <utility>
22 #include <limits>
23 #include <testsuite_hooks.h>
24
25 void
26 test01()
27 {
28 unsigned int u = std::numeric_limits<unsigned int>::max();
29 int s = -1;
30 VERIFY( std::cmp_not_equal(s, u) );
31 VERIFY( std::cmp_not_equal(u, s) );
32 }
33
34 constexpr bool
35 test02()
36 {
37 unsigned int u = std::numeric_limits<unsigned int>::max();
38 int s = -1;
39 if (!std::cmp_not_equal(s, u))
40 throw 1;
41 if (!std::cmp_not_equal(u, s))
42 throw 2;
43 return true;
44 }
45
46 void
47 test03()
48 {
49 short ss = -1;
50 int s = -1;
51 VERIFY( !std::cmp_not_equal(s, ss) );
52 VERIFY( !std::cmp_not_equal(ss, s) );
53
54 unsigned int u = (unsigned int) -1;
55 VERIFY( std::cmp_not_equal(s, u) );
56 VERIFY( std::cmp_not_equal(u, s) );
57 VERIFY( std::cmp_not_equal(ss, u) );
58 VERIFY( std::cmp_not_equal(u, ss) );
59
60 unsigned long long ul = (unsigned long long) -1;
61 VERIFY( std::cmp_not_equal(s, ul) );
62 VERIFY( std::cmp_not_equal(ul, s) );
63 VERIFY( std::cmp_not_equal(ss, ul) );
64 VERIFY( std::cmp_not_equal(ul, ss) );
65 VERIFY( std::cmp_not_equal(u, ul) );
66 VERIFY( std::cmp_not_equal(ul, u) );
67 }
68
69 int
70 main()
71 {
72 test01();
73 static_assert( test02() );
74 test03();
75 }