aboutsummaryrefslogtreecommitdiff
path: root/test/std/language.support/support.limits/limits/numeric.limits.members/const_data_members.pass.cpp
blob: 50cfc4674251436185fdf6450becfea01dcc4b10 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include <limits>

/*
<limits>:
    numeric_limits
        is_specialized
        digits
        digits10
        max_digits10
        is_signed
        is_integer
        is_exact
        radix
        min_exponent
        min_exponent10
        max_exponent
        max_exponent10
        has_infinity
        has_quiet_NaN
        has_signaling_NaN
        has_denorm
        has_denorm_loss
        is_iec559
        is_bounded
        is_modulo
        traps
        tinyness_before
        round_style
*/

template <class _Tp>
void test(const _Tp &) {}

#define TEST_NUMERIC_LIMITS(type) \
  test(std::numeric_limits<type>::is_specialized); \
  test(std::numeric_limits<type>::digits); \
  test(std::numeric_limits<type>::digits10); \
  test(std::numeric_limits<type>::max_digits10); \
  test(std::numeric_limits<type>::is_signed); \
  test(std::numeric_limits<type>::is_integer); \
  test(std::numeric_limits<type>::is_exact); \
  test(std::numeric_limits<type>::radix); \
  test(std::numeric_limits<type>::min_exponent); \
  test(std::numeric_limits<type>::min_exponent10); \
  test(std::numeric_limits<type>::max_exponent); \
  test(std::numeric_limits<type>::max_exponent10); \
  test(std::numeric_limits<type>::has_infinity); \
  test(std::numeric_limits<type>::has_quiet_NaN); \
  test(std::numeric_limits<type>::has_signaling_NaN); \
  test(std::numeric_limits<type>::has_denorm); \
  test(std::numeric_limits<type>::has_denorm_loss); \
  test(std::numeric_limits<type>::is_iec559); \
  test(std::numeric_limits<type>::is_bounded); \
  test(std::numeric_limits<type>::is_modulo); \
  test(std::numeric_limits<type>::traps); \
  test(std::numeric_limits<type>::tinyness_before); \
  test(std::numeric_limits<type>::round_style);

struct other {};

int main()
{
    // bool
    TEST_NUMERIC_LIMITS(bool)
    TEST_NUMERIC_LIMITS(const bool)
    TEST_NUMERIC_LIMITS(volatile bool)
    TEST_NUMERIC_LIMITS(const volatile bool)

    // char
    TEST_NUMERIC_LIMITS(char)
    TEST_NUMERIC_LIMITS(const char)
    TEST_NUMERIC_LIMITS(volatile char)
    TEST_NUMERIC_LIMITS(const volatile char)

    // signed char
    TEST_NUMERIC_LIMITS(signed char)
    TEST_NUMERIC_LIMITS(const signed char)
    TEST_NUMERIC_LIMITS(volatile signed char)
    TEST_NUMERIC_LIMITS(const volatile signed char)

    // unsigned char
    TEST_NUMERIC_LIMITS(unsigned char)
    TEST_NUMERIC_LIMITS(const unsigned char)
    TEST_NUMERIC_LIMITS(volatile unsigned char)
    TEST_NUMERIC_LIMITS(const volatile unsigned char)

    // wchar_t
    TEST_NUMERIC_LIMITS(wchar_t)
    TEST_NUMERIC_LIMITS(const wchar_t)
    TEST_NUMERIC_LIMITS(volatile wchar_t)
    TEST_NUMERIC_LIMITS(const volatile wchar_t)

    // char16_t
    TEST_NUMERIC_LIMITS(char16_t)
    TEST_NUMERIC_LIMITS(const char16_t)
    TEST_NUMERIC_LIMITS(volatile char16_t)
    TEST_NUMERIC_LIMITS(const volatile char16_t)

    // char32_t
    TEST_NUMERIC_LIMITS(char32_t)
    TEST_NUMERIC_LIMITS(const char32_t)
    TEST_NUMERIC_LIMITS(volatile char32_t)
    TEST_NUMERIC_LIMITS(const volatile char32_t)

    // short
    TEST_NUMERIC_LIMITS(short)
    TEST_NUMERIC_LIMITS(const short)
    TEST_NUMERIC_LIMITS(volatile short)
    TEST_NUMERIC_LIMITS(const volatile short)

    // int
    TEST_NUMERIC_LIMITS(int)
    TEST_NUMERIC_LIMITS(const int)
    TEST_NUMERIC_LIMITS(volatile int)
    TEST_NUMERIC_LIMITS(const volatile int)

    // long
    TEST_NUMERIC_LIMITS(long)
    TEST_NUMERIC_LIMITS(const long)
    TEST_NUMERIC_LIMITS(volatile long)
    TEST_NUMERIC_LIMITS(const volatile long)

#ifndef _LIBCPP_HAS_NO_INT128
    TEST_NUMERIC_LIMITS(__int128_t)
    TEST_NUMERIC_LIMITS(const __int128_t)
    TEST_NUMERIC_LIMITS(volatile __int128_t)
    TEST_NUMERIC_LIMITS(const volatile __int128_t)
#endif

    // long long
    TEST_NUMERIC_LIMITS(long long)
    TEST_NUMERIC_LIMITS(const long long)
    TEST_NUMERIC_LIMITS(volatile long long)
    TEST_NUMERIC_LIMITS(const volatile long long)

    // unsigned short
    TEST_NUMERIC_LIMITS(unsigned short)
    TEST_NUMERIC_LIMITS(const unsigned short)
    TEST_NUMERIC_LIMITS(volatile unsigned short)
    TEST_NUMERIC_LIMITS(const volatile unsigned short)

    // unsigned int
    TEST_NUMERIC_LIMITS(unsigned int)
    TEST_NUMERIC_LIMITS(const unsigned int)
    TEST_NUMERIC_LIMITS(volatile unsigned int)
    TEST_NUMERIC_LIMITS(const volatile unsigned int)

    // unsigned long
    TEST_NUMERIC_LIMITS(unsigned long)
    TEST_NUMERIC_LIMITS(const unsigned long)
    TEST_NUMERIC_LIMITS(volatile unsigned long)
    TEST_NUMERIC_LIMITS(const volatile unsigned long)

    // unsigned long long
    TEST_NUMERIC_LIMITS(unsigned long long)
    TEST_NUMERIC_LIMITS(const unsigned long long)
    TEST_NUMERIC_LIMITS(volatile unsigned long long)
    TEST_NUMERIC_LIMITS(const volatile unsigned long long)

#ifndef _LIBCPP_HAS_NO_INT128
    TEST_NUMERIC_LIMITS(__uint128_t)
    TEST_NUMERIC_LIMITS(const __uint128_t)
    TEST_NUMERIC_LIMITS(volatile __uint128_t)
    TEST_NUMERIC_LIMITS(const volatile __uint128_t)
#endif

    // float
    TEST_NUMERIC_LIMITS(float)
    TEST_NUMERIC_LIMITS(const float)
    TEST_NUMERIC_LIMITS(volatile float)
    TEST_NUMERIC_LIMITS(const volatile float)

    // double
    TEST_NUMERIC_LIMITS(double)
    TEST_NUMERIC_LIMITS(const double)
    TEST_NUMERIC_LIMITS(volatile double)
    TEST_NUMERIC_LIMITS(const volatile double)

    // long double
    TEST_NUMERIC_LIMITS(long double)
    TEST_NUMERIC_LIMITS(const long double)
    TEST_NUMERIC_LIMITS(volatile long double)
    TEST_NUMERIC_LIMITS(const volatile long double)

    // other
    TEST_NUMERIC_LIMITS(other)
    TEST_NUMERIC_LIMITS(const other)
    TEST_NUMERIC_LIMITS(volatile other)
    TEST_NUMERIC_LIMITS(const volatile other)
}