Upstream version 8.36.169.0
[platform/framework/web/crosswalk.git] / src / third_party / libc++ / trunk / test / language.support / support.limits / limits / numeric.limits.members / max.pass.cpp
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 // test numeric_limits
11
12 // max()
13
14 #include <limits>
15 #include <climits>
16 #include <cwchar>
17 #include <cfloat>
18 #include <cassert>
19
20 template <class T>
21 void
22 test(T expected)
23 {
24     assert(std::numeric_limits<T>::max() == expected);
25     assert(std::numeric_limits<T>::is_bounded);
26     assert(std::numeric_limits<const T>::max() == expected);
27     assert(std::numeric_limits<const T>::is_bounded);
28     assert(std::numeric_limits<volatile T>::max() == expected);
29     assert(std::numeric_limits<volatile T>::is_bounded);
30     assert(std::numeric_limits<const volatile T>::max() == expected);
31     assert(std::numeric_limits<const volatile T>::is_bounded);
32 }
33
34 int main()
35 {
36     test<bool>(true);
37     test<char>(CHAR_MAX);
38     test<signed char>(SCHAR_MAX);
39     test<unsigned char>(UCHAR_MAX);
40     test<wchar_t>(WCHAR_MAX);
41 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
42     test<char16_t>(USHRT_MAX);
43     test<char32_t>(UINT_MAX);
44 #endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
45     test<short>(SHRT_MAX);
46     test<unsigned short>(USHRT_MAX);
47     test<int>(INT_MAX);
48     test<unsigned int>(UINT_MAX);
49     test<long>(LONG_MAX);
50     test<unsigned long>(ULONG_MAX);
51     test<long long>(LLONG_MAX);
52     test<unsigned long long>(ULLONG_MAX);
53 #ifndef _LIBCPP_HAS_NO_INT128
54     test<__int128_t>(__int128_t(__uint128_t(-1)/2));
55     test<__uint128_t>(__uint128_t(-1));
56 #endif
57     test<float>(FLT_MAX);
58     test<double>(DBL_MAX);
59     test<long double>(LDBL_MAX);
60 }