//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // test numeric_limits // max() #include #include #include #include #include "test_macros.h" #ifndef TEST_HAS_NO_WIDE_CHARACTERS # include #endif template void test(T expected) { assert(std::numeric_limits::max() == expected); assert(std::numeric_limits::is_bounded); assert(std::numeric_limits::max() == expected); assert(std::numeric_limits::is_bounded); assert(std::numeric_limits::max() == expected); assert(std::numeric_limits::is_bounded); assert(std::numeric_limits::max() == expected); assert(std::numeric_limits::is_bounded); } int main(int, char**) { test(true); test(CHAR_MAX); test(SCHAR_MAX); test(UCHAR_MAX); #ifndef TEST_HAS_NO_WIDE_CHARACTERS test(WCHAR_MAX); #endif #if TEST_STD_VER > 17 && defined(__cpp_char8_t) test(UCHAR_MAX); // ?? #endif test(USHRT_MAX); test(UINT_MAX); test(SHRT_MAX); test(USHRT_MAX); test(INT_MAX); test(UINT_MAX); test(LONG_MAX); test(ULONG_MAX); test(LLONG_MAX); test(ULLONG_MAX); #ifndef TEST_HAS_NO_INT128 test<__int128_t>(__int128_t(__uint128_t(-1)/2)); test<__uint128_t>(__uint128_t(-1)); #endif test(FLT_MAX); test(DBL_MAX); test(LDBL_MAX); return 0; }