Debian Codegraph @

libstdc++-v3/testsuite/20_util/is_unsigned/value.cc

raw
1 // { dg-do compile { target c++11 } }
2
3 // 2005-01-24 Paolo Carlini <[email protected]>
4 //
5 // Copyright (C) 2005-2025 Free Software Foundation, Inc.
6 //
7 // This file is part of the GNU ISO C++ Library. This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 3, or (at your option)
11 // any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License along
19 // with this library; see the file COPYING3. If not see
20 // <http://www.gnu.org/licenses/>.
21
22 #include <type_traits>
23 #include <testsuite_tr1.h>
24
25 void test01()
26 {
27 using std::is_unsigned;
28 using namespace __gnu_test;
29
30 static_assert(test_category<is_unsigned, void>(false), "");
31
32 static_assert(test_category<is_unsigned, char>(char(-1) > char(0)), "");
33 static_assert(test_category<is_unsigned, signed char>(false), "");
34 static_assert(test_category<is_unsigned, unsigned char>(true), "");
35 static_assert(test_category<is_unsigned, wchar_t>
36 (wchar_t(-1) > wchar_t(0)), "");
37 static_assert(test_category<is_unsigned, short>(false), "");
38 static_assert(test_category<is_unsigned, unsigned short>(true), "");
39 static_assert(test_category<is_unsigned, int>(false), "");
40 static_assert(test_category<is_unsigned, unsigned int>(true), "");
41 static_assert(test_category<is_unsigned, long>(false), "");
42 static_assert(test_category<is_unsigned, unsigned long>(true), "");
43 static_assert(test_category<is_unsigned, long long>(false), "");
44 static_assert(test_category<is_unsigned, unsigned long long>(true), "");
45
46 static_assert(test_category<is_unsigned, float>(false), "");
47 static_assert(test_category<is_unsigned, double>(false), "");
48 static_assert(test_category<is_unsigned, long double>(false), "");
49
50 #ifndef __STRICT_ANSI__
51 // GNU Extensions.
52 #ifdef __SIZEOF_INT128__
53 static_assert(test_category<is_unsigned, unsigned __int128>(true), "");
54 static_assert(test_category<is_unsigned, __int128>(false), "");
55 #endif
56
57 #ifdef _GLIBCXX_USE_FLOAT128
58 static_assert(test_category<is_unsigned, __float128>(false), "");
59 #endif
60 #endif
61
62 // Sanity check.
63 static_assert(test_category<is_unsigned, ClassType>(false), "");
64 }