libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

const_data_members.pass.cpp (6331B)


      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 #include <limits>
     11 
     12 #include "test_macros.h"
     13 
     14 /*
     15 <limits>:
     16     numeric_limits
     17         is_specialized
     18         digits
     19         digits10
     20         max_digits10
     21         is_signed
     22         is_integer
     23         is_exact
     24         radix
     25         min_exponent
     26         min_exponent10
     27         max_exponent
     28         max_exponent10
     29         has_infinity
     30         has_quiet_NaN
     31         has_signaling_NaN
     32         has_denorm
     33         has_denorm_loss
     34         is_iec559
     35         is_bounded
     36         is_modulo
     37         traps
     38         tinyness_before
     39         round_style
     40 */
     41 
     42 template <class T>
     43 void test(const T &) {}
     44 
     45 #define TEST_NUMERIC_LIMITS(type) \
     46   test(std::numeric_limits<type>::is_specialized); \
     47   test(std::numeric_limits<type>::digits); \
     48   test(std::numeric_limits<type>::digits10); \
     49   test(std::numeric_limits<type>::max_digits10); \
     50   test(std::numeric_limits<type>::is_signed); \
     51   test(std::numeric_limits<type>::is_integer); \
     52   test(std::numeric_limits<type>::is_exact); \
     53   test(std::numeric_limits<type>::radix); \
     54   test(std::numeric_limits<type>::min_exponent); \
     55   test(std::numeric_limits<type>::min_exponent10); \
     56   test(std::numeric_limits<type>::max_exponent); \
     57   test(std::numeric_limits<type>::max_exponent10); \
     58   test(std::numeric_limits<type>::has_infinity); \
     59   test(std::numeric_limits<type>::has_quiet_NaN); \
     60   test(std::numeric_limits<type>::has_signaling_NaN); \
     61   test(std::numeric_limits<type>::has_denorm); \
     62   test(std::numeric_limits<type>::has_denorm_loss); \
     63   test(std::numeric_limits<type>::is_iec559); \
     64   test(std::numeric_limits<type>::is_bounded); \
     65   test(std::numeric_limits<type>::is_modulo); \
     66   test(std::numeric_limits<type>::traps); \
     67   test(std::numeric_limits<type>::tinyness_before); \
     68   test(std::numeric_limits<type>::round_style);
     69 
     70 struct other {};
     71 
     72 int main()
     73 {
     74     // bool
     75     TEST_NUMERIC_LIMITS(bool)
     76     TEST_NUMERIC_LIMITS(const bool)
     77     TEST_NUMERIC_LIMITS(volatile bool)
     78     TEST_NUMERIC_LIMITS(const volatile bool)
     79 
     80     // char
     81     TEST_NUMERIC_LIMITS(char)
     82     TEST_NUMERIC_LIMITS(const char)
     83     TEST_NUMERIC_LIMITS(volatile char)
     84     TEST_NUMERIC_LIMITS(const volatile char)
     85 
     86     // signed char
     87     TEST_NUMERIC_LIMITS(signed char)
     88     TEST_NUMERIC_LIMITS(const signed char)
     89     TEST_NUMERIC_LIMITS(volatile signed char)
     90     TEST_NUMERIC_LIMITS(const volatile signed char)
     91 
     92     // unsigned char
     93     TEST_NUMERIC_LIMITS(unsigned char)
     94     TEST_NUMERIC_LIMITS(const unsigned char)
     95     TEST_NUMERIC_LIMITS(volatile unsigned char)
     96     TEST_NUMERIC_LIMITS(const volatile unsigned char)
     97 
     98     // wchar_t
     99     TEST_NUMERIC_LIMITS(wchar_t)
    100     TEST_NUMERIC_LIMITS(const wchar_t)
    101     TEST_NUMERIC_LIMITS(volatile wchar_t)
    102     TEST_NUMERIC_LIMITS(const volatile wchar_t)
    103 
    104 #if TEST_STD_VER > 17 && defined(__cpp_char8_t)
    105     // char8_t
    106     TEST_NUMERIC_LIMITS(char8_t)
    107     TEST_NUMERIC_LIMITS(const char8_t)
    108     TEST_NUMERIC_LIMITS(volatile char8_t)
    109     TEST_NUMERIC_LIMITS(const volatile char8_t)
    110 #endif
    111 
    112     // char16_t
    113     TEST_NUMERIC_LIMITS(char16_t)
    114     TEST_NUMERIC_LIMITS(const char16_t)
    115     TEST_NUMERIC_LIMITS(volatile char16_t)
    116     TEST_NUMERIC_LIMITS(const volatile char16_t)
    117 
    118     // char32_t
    119     TEST_NUMERIC_LIMITS(char32_t)
    120     TEST_NUMERIC_LIMITS(const char32_t)
    121     TEST_NUMERIC_LIMITS(volatile char32_t)
    122     TEST_NUMERIC_LIMITS(const volatile char32_t)
    123 
    124     // short
    125     TEST_NUMERIC_LIMITS(short)
    126     TEST_NUMERIC_LIMITS(const short)
    127     TEST_NUMERIC_LIMITS(volatile short)
    128     TEST_NUMERIC_LIMITS(const volatile short)
    129 
    130     // int
    131     TEST_NUMERIC_LIMITS(int)
    132     TEST_NUMERIC_LIMITS(const int)
    133     TEST_NUMERIC_LIMITS(volatile int)
    134     TEST_NUMERIC_LIMITS(const volatile int)
    135 
    136     // long
    137     TEST_NUMERIC_LIMITS(long)
    138     TEST_NUMERIC_LIMITS(const long)
    139     TEST_NUMERIC_LIMITS(volatile long)
    140     TEST_NUMERIC_LIMITS(const volatile long)
    141 
    142 #ifndef _LIBCPP_HAS_NO_INT128
    143     TEST_NUMERIC_LIMITS(__int128_t)
    144     TEST_NUMERIC_LIMITS(const __int128_t)
    145     TEST_NUMERIC_LIMITS(volatile __int128_t)
    146     TEST_NUMERIC_LIMITS(const volatile __int128_t)
    147 #endif
    148 
    149     // long long
    150     TEST_NUMERIC_LIMITS(long long)
    151     TEST_NUMERIC_LIMITS(const long long)
    152     TEST_NUMERIC_LIMITS(volatile long long)
    153     TEST_NUMERIC_LIMITS(const volatile long long)
    154 
    155     // unsigned short
    156     TEST_NUMERIC_LIMITS(unsigned short)
    157     TEST_NUMERIC_LIMITS(const unsigned short)
    158     TEST_NUMERIC_LIMITS(volatile unsigned short)
    159     TEST_NUMERIC_LIMITS(const volatile unsigned short)
    160 
    161     // unsigned int
    162     TEST_NUMERIC_LIMITS(unsigned int)
    163     TEST_NUMERIC_LIMITS(const unsigned int)
    164     TEST_NUMERIC_LIMITS(volatile unsigned int)
    165     TEST_NUMERIC_LIMITS(const volatile unsigned int)
    166 
    167     // unsigned long
    168     TEST_NUMERIC_LIMITS(unsigned long)
    169     TEST_NUMERIC_LIMITS(const unsigned long)
    170     TEST_NUMERIC_LIMITS(volatile unsigned long)
    171     TEST_NUMERIC_LIMITS(const volatile unsigned long)
    172 
    173     // unsigned long long
    174     TEST_NUMERIC_LIMITS(unsigned long long)
    175     TEST_NUMERIC_LIMITS(const unsigned long long)
    176     TEST_NUMERIC_LIMITS(volatile unsigned long long)
    177     TEST_NUMERIC_LIMITS(const volatile unsigned long long)
    178 
    179 #ifndef _LIBCPP_HAS_NO_INT128
    180     TEST_NUMERIC_LIMITS(__uint128_t)
    181     TEST_NUMERIC_LIMITS(const __uint128_t)
    182     TEST_NUMERIC_LIMITS(volatile __uint128_t)
    183     TEST_NUMERIC_LIMITS(const volatile __uint128_t)
    184 #endif
    185 
    186     // float
    187     TEST_NUMERIC_LIMITS(float)
    188     TEST_NUMERIC_LIMITS(const float)
    189     TEST_NUMERIC_LIMITS(volatile float)
    190     TEST_NUMERIC_LIMITS(const volatile float)
    191 
    192     // double
    193     TEST_NUMERIC_LIMITS(double)
    194     TEST_NUMERIC_LIMITS(const double)
    195     TEST_NUMERIC_LIMITS(volatile double)
    196     TEST_NUMERIC_LIMITS(const volatile double)
    197 
    198     // long double
    199     TEST_NUMERIC_LIMITS(long double)
    200     TEST_NUMERIC_LIMITS(const long double)
    201     TEST_NUMERIC_LIMITS(volatile long double)
    202     TEST_NUMERIC_LIMITS(const volatile long double)
    203 
    204     // other
    205     TEST_NUMERIC_LIMITS(other)
    206     TEST_NUMERIC_LIMITS(const other)
    207     TEST_NUMERIC_LIMITS(volatile other)
    208     TEST_NUMERIC_LIMITS(const volatile other)
    209 }