1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
13 #include <type_traits>
14 #include "test_macros.h"
17 void test_is_unsigned()
19 static_assert( std::is_unsigned
<T
>::value
, "");
20 static_assert( std::is_unsigned
<const T
>::value
, "");
21 static_assert( std::is_unsigned
<volatile T
>::value
, "");
22 static_assert( std::is_unsigned
<const volatile T
>::value
, "");
24 static_assert( std::is_unsigned_v
<T
>, "");
25 static_assert( std::is_unsigned_v
<const T
>, "");
26 static_assert( std::is_unsigned_v
<volatile T
>, "");
27 static_assert( std::is_unsigned_v
<const volatile T
>, "");
32 void test_is_not_unsigned()
34 static_assert(!std::is_unsigned
<T
>::value
, "");
35 static_assert(!std::is_unsigned
<const T
>::value
, "");
36 static_assert(!std::is_unsigned
<volatile T
>::value
, "");
37 static_assert(!std::is_unsigned
<const volatile T
>::value
, "");
39 static_assert(!std::is_unsigned_v
<T
>, "");
40 static_assert(!std::is_unsigned_v
<const T
>, "");
41 static_assert(!std::is_unsigned_v
<volatile T
>, "");
42 static_assert(!std::is_unsigned_v
<const volatile T
>, "");
52 struct A
; // incomplete
54 class incomplete_type
;
69 virtual ~Abstract() = 0;
72 enum Enum
{ zero
, one
};
74 enum EnumSigned
: int { two
};
76 enum EnumUnsigned
: unsigned { three
};
78 enum class EnumClass
{ zero
, one
};
80 typedef void (*FunctionPtr
)();
84 // Cases where !is_arithmetic implies !is_unsigned
85 test_is_not_unsigned
<std::nullptr_t
>();
86 test_is_not_unsigned
<void>();
87 test_is_not_unsigned
<int&>();
88 test_is_not_unsigned
<int&&>();
89 test_is_not_unsigned
<Class
>();
90 test_is_not_unsigned
<int*>();
91 test_is_not_unsigned
<const int*>();
92 test_is_not_unsigned
<char[3]>();
93 test_is_not_unsigned
<char[]>();
94 test_is_not_unsigned
<Union
>();
95 test_is_not_unsigned
<Enum
>();
96 test_is_not_unsigned
<EnumSigned
>();
97 test_is_not_unsigned
<EnumUnsigned
>();
98 test_is_not_unsigned
<EnumClass
>();
99 test_is_not_unsigned
<FunctionPtr
>();
100 test_is_not_unsigned
<Empty
>();
101 test_is_not_unsigned
<incomplete_type
>();
102 test_is_not_unsigned
<A
>();
103 test_is_not_unsigned
<bit_zero
>();
104 test_is_not_unsigned
<NotEmpty
>();
105 test_is_not_unsigned
<Abstract
>();
107 test_is_not_unsigned
<signed char>();
108 test_is_not_unsigned
<short>();
109 test_is_not_unsigned
<int>();
110 test_is_not_unsigned
<long>();
111 test_is_not_unsigned
<float>();
112 test_is_not_unsigned
<double>();
114 test_is_unsigned
<unsigned char>();
115 test_is_unsigned
<unsigned short>();
116 test_is_unsigned
<unsigned int>();
117 test_is_unsigned
<unsigned long>();
119 test_is_unsigned
<bool>();
120 test_is_unsigned
<unsigned>();
122 #ifndef TEST_HAS_NO_INT128
123 test_is_unsigned
<__uint128_t
>();
124 test_is_not_unsigned
<__int128_t
>();