libcxx initial import

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@103490 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant
2010-05-11 19:42:16 +00:00
commit bc8d3f97eb
3893 changed files with 1209942 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// denorm_min()
#include <limits>
#include <cassert>
template <class T>
void
test(T expected)
{
assert(std::numeric_limits<T>::denorm_min() == expected);
assert(std::numeric_limits<const T>::denorm_min() == expected);
assert(std::numeric_limits<volatile T>::denorm_min() == expected);
assert(std::numeric_limits<const volatile T>::denorm_min() == expected);
}
int main()
{
test<bool>(false);
test<char>(0);
test<signed char>(0);
test<unsigned char>(0);
test<wchar_t>(0);
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>(0);
test<char32_t>(0);
#endif
test<short>(0);
test<unsigned short>(0);
test<int>(0);
test<unsigned int>(0);
test<long>(0);
test<unsigned long>(0);
test<long long>(0);
test<unsigned long long>(0);
test<float>(__FLT_DENORM_MIN__);
test<double>(__DBL_DENORM_MIN__);
test<long double>(__LDBL_DENORM_MIN__);
}

View File

@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// digits
#include <limits>
#include <cfloat>
template <class T, int expected>
void
test()
{
static_assert(std::numeric_limits<T>::digits == expected, "digits test 1");
static_assert(std::numeric_limits<const T>::digits == expected, "digits test 2");
static_assert(std::numeric_limits<volatile T>::digits == expected, "digits test 3");
static_assert(std::numeric_limits<const volatile T>::digits == expected, "digits test 4");
}
int main()
{
test<bool, 1>();
test<char, std::numeric_limits<char>::is_signed ? 7 : 8>();
test<signed char, 7>();
test<unsigned char, 8>();
test<wchar_t, std::numeric_limits<wchar_t>::is_signed ? 31 : 32>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, 16>();
test<char32_t, 32>();
#endif
test<short, 15>();
test<unsigned short, 16>();
test<int, 31>();
test<unsigned int, 32>();
test<long, sizeof(long) == 4 ? 31 : 63>();
test<unsigned long, sizeof(long) == 4 ? 32 : 64>();
test<long long, 63>();
test<unsigned long long, 64>();
test<float, FLT_MANT_DIG>();
test<double, DBL_MANT_DIG>();
test<long double, LDBL_MANT_DIG>();
}

View File

@@ -0,0 +1,53 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// digits10
#include <limits>
#include <cfloat>
template <class T, int expected>
void
test()
{
static_assert(std::numeric_limits<T>::digits10 == expected, "digits10 test 1");
static_assert(std::numeric_limits<T>::is_bounded, "digits10 test 5");
static_assert(std::numeric_limits<const T>::digits10 == expected, "digits10 test 2");
static_assert(std::numeric_limits<const T>::is_bounded, "digits10 test 6");
static_assert(std::numeric_limits<volatile T>::digits10 == expected, "digits10 test 3");
static_assert(std::numeric_limits<volatile T>::is_bounded, "digits10 test 7");
static_assert(std::numeric_limits<const volatile T>::digits10 == expected, "digits10 test 4");
static_assert(std::numeric_limits<const volatile T>::is_bounded, "digits10 test 8");
}
int main()
{
test<bool, 0>();
test<char, 2>();
test<signed char, 2>();
test<unsigned char, 2>();
test<wchar_t, 9>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, 4>();
test<char32_t, 9>();
#endif
test<short, 4>();
test<unsigned short, 4>();
test<int, 9>();
test<unsigned int, 9>();
test<long, sizeof(long) == 4 ? 9 : 18>();
test<unsigned long, sizeof(long) == 4 ? 9 : 19>();
test<long long, 18>();
test<unsigned long long, 19>();
test<float, FLT_DIG>();
test<double, DBL_DIG>();
test<long double, LDBL_DIG>();
}

View File

@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// epsilon()
#include <limits>
#include <cfloat>
#include <cassert>
template <class T>
void
test(T expected)
{
assert(std::numeric_limits<T>::epsilon() == expected);
assert(std::numeric_limits<const T>::epsilon() == expected);
assert(std::numeric_limits<volatile T>::epsilon() == expected);
assert(std::numeric_limits<const volatile T>::epsilon() == expected);
}
int main()
{
test<bool>(false);
test<char>(0);
test<signed char>(0);
test<unsigned char>(0);
test<wchar_t>(0);
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>(0);
test<char32_t>(0);
#endif
test<short>(0);
test<unsigned short>(0);
test<int>(0);
test<unsigned int>(0);
test<long>(0);
test<unsigned long>(0);
test<long long>(0);
test<unsigned long long>(0);
test<float>(FLT_EPSILON);
test<double>(DBL_EPSILON);
test<long double>(LDBL_EPSILON);
}

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// has_denorm
#include <limits>
template <class T, std::float_denorm_style expected>
void
test()
{
static_assert(std::numeric_limits<T>::has_denorm == expected, "has_denorm test 1");
static_assert(std::numeric_limits<const T>::has_denorm == expected, "has_denorm test 2");
static_assert(std::numeric_limits<volatile T>::has_denorm == expected, "has_denorm test 3");
static_assert(std::numeric_limits<const volatile T>::has_denorm == expected, "has_denorm test 4");
}
int main()
{
test<bool, std::denorm_absent>();
test<char, std::denorm_absent>();
test<signed char, std::denorm_absent>();
test<unsigned char, std::denorm_absent>();
test<wchar_t, std::denorm_absent>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, std::denorm_absent>();
test<char32_t, std::denorm_absent>();
#endif
test<short, std::denorm_absent>();
test<unsigned short, std::denorm_absent>();
test<int, std::denorm_absent>();
test<unsigned int, std::denorm_absent>();
test<long, std::denorm_absent>();
test<unsigned long, std::denorm_absent>();
test<long long, std::denorm_absent>();
test<unsigned long long, std::denorm_absent>();
test<float, std::denorm_present>();
test<double, std::denorm_present>();
test<long double, std::denorm_present>();
}

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// has_denorm_loss
#include <limits>
template <class T, bool expected>
void
test()
{
static_assert(std::numeric_limits<T>::has_denorm_loss == expected, "has_denorm_loss test 1");
static_assert(std::numeric_limits<const T>::has_denorm_loss == expected, "has_denorm_loss test 2");
static_assert(std::numeric_limits<volatile T>::has_denorm_loss == expected, "has_denorm_loss test 3");
static_assert(std::numeric_limits<const volatile T>::has_denorm_loss == expected, "has_denorm_loss test 4");
}
int main()
{
test<bool, false>();
test<char, false>();
test<signed char, false>();
test<unsigned char, false>();
test<wchar_t, false>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, false>();
test<char32_t, false>();
#endif
test<short, false>();
test<unsigned short, false>();
test<int, false>();
test<unsigned int, false>();
test<long, false>();
test<unsigned long, false>();
test<long long, false>();
test<unsigned long long, false>();
test<float, false>();
test<double, false>();
test<long double, false>();
}

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// has_infinity
#include <limits>
template <class T, bool expected>
void
test()
{
static_assert(std::numeric_limits<T>::has_infinity == expected, "has_infinity test 1");
static_assert(std::numeric_limits<const T>::has_infinity == expected, "has_infinity test 2");
static_assert(std::numeric_limits<volatile T>::has_infinity == expected, "has_infinity test 3");
static_assert(std::numeric_limits<const volatile T>::has_infinity == expected, "has_infinity test 4");
}
int main()
{
test<bool, false>();
test<char, false>();
test<signed char, false>();
test<unsigned char, false>();
test<wchar_t, false>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, false>();
test<char32_t, false>();
#endif
test<short, false>();
test<unsigned short, false>();
test<int, false>();
test<unsigned int, false>();
test<long, false>();
test<unsigned long, false>();
test<long long, false>();
test<unsigned long long, false>();
test<float, true>();
test<double, true>();
test<long double, true>();
}

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// has_quiet_NaN
#include <limits>
template <class T, bool expected>
void
test()
{
static_assert(std::numeric_limits<T>::has_quiet_NaN == expected, "has_quiet_NaN test 1");
static_assert(std::numeric_limits<const T>::has_quiet_NaN == expected, "has_quiet_NaN test 2");
static_assert(std::numeric_limits<volatile T>::has_quiet_NaN == expected, "has_quiet_NaN test 3");
static_assert(std::numeric_limits<const volatile T>::has_quiet_NaN == expected, "has_quiet_NaN test 4");
}
int main()
{
test<bool, false>();
test<char, false>();
test<signed char, false>();
test<unsigned char, false>();
test<wchar_t, false>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, false>();
test<char32_t, false>();
#endif
test<short, false>();
test<unsigned short, false>();
test<int, false>();
test<unsigned int, false>();
test<long, false>();
test<unsigned long, false>();
test<long long, false>();
test<unsigned long long, false>();
test<float, true>();
test<double, true>();
test<long double, true>();
}

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// has_signaling_NaN
#include <limits>
template <class T, bool expected>
void
test()
{
static_assert(std::numeric_limits<T>::has_signaling_NaN == expected, "has_signaling_NaN test 1");
static_assert(std::numeric_limits<const T>::has_signaling_NaN == expected, "has_signaling_NaN test 2");
static_assert(std::numeric_limits<volatile T>::has_signaling_NaN == expected, "has_signaling_NaN test 3");
static_assert(std::numeric_limits<const volatile T>::has_signaling_NaN == expected, "has_signaling_NaN test 4");
}
int main()
{
test<bool, false>();
test<char, false>();
test<signed char, false>();
test<unsigned char, false>();
test<wchar_t, false>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, false>();
test<char32_t, false>();
#endif
test<short, false>();
test<unsigned short, false>();
test<int, false>();
test<unsigned int, false>();
test<long, false>();
test<unsigned long, false>();
test<long long, false>();
test<unsigned long long, false>();
test<float, true>();
test<double, true>();
test<long double, true>();
}

View File

@@ -0,0 +1,54 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// infinity()
#include <limits>
#include <cfloat>
#include <cassert>
template <class T>
void
test(T expected)
{
assert(std::numeric_limits<T>::infinity() == expected);
assert(std::numeric_limits<const T>::infinity() == expected);
assert(std::numeric_limits<volatile T>::infinity() == expected);
assert(std::numeric_limits<const volatile T>::infinity() == expected);
}
extern float zero;
int main()
{
test<bool>(false);
test<char>(0);
test<signed char>(0);
test<unsigned char>(0);
test<wchar_t>(0);
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>(0);
test<char32_t>(0);
#endif
test<short>(0);
test<unsigned short>(0);
test<int>(0);
test<unsigned int>(0);
test<long>(0);
test<unsigned long>(0);
test<long long>(0);
test<unsigned long long>(0);
test<float>(1./zero);
test<double>(1./zero);
test<long double>(1./zero);
}
float zero = 0;

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// is_bounded
#include <limits>
template <class T, bool expected>
void
test()
{
static_assert(std::numeric_limits<T>::is_bounded == expected, "is_bounded test 1");
static_assert(std::numeric_limits<const T>::is_bounded == expected, "is_bounded test 2");
static_assert(std::numeric_limits<volatile T>::is_bounded == expected, "is_bounded test 3");
static_assert(std::numeric_limits<const volatile T>::is_bounded == expected, "is_bounded test 4");
}
int main()
{
test<bool, true>();
test<char, true>();
test<signed char, true>();
test<unsigned char, true>();
test<wchar_t, true>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, true>();
test<char32_t, true>();
#endif
test<short, true>();
test<unsigned short, true>();
test<int, true>();
test<unsigned int, true>();
test<long, true>();
test<unsigned long, true>();
test<long long, true>();
test<unsigned long long, true>();
test<float, true>();
test<double, true>();
test<long double, true>();
}

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// is_exact
#include <limits>
template <class T, bool expected>
void
test()
{
static_assert(std::numeric_limits<T>::is_exact == expected, "is_exact test 1");
static_assert(std::numeric_limits<const T>::is_exact == expected, "is_exact test 2");
static_assert(std::numeric_limits<volatile T>::is_exact == expected, "is_exact test 3");
static_assert(std::numeric_limits<const volatile T>::is_exact == expected, "is_exact test 4");
}
int main()
{
test<bool, true>();
test<char, true>();
test<signed char, true>();
test<unsigned char, true>();
test<wchar_t, true>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, true>();
test<char32_t, true>();
#endif
test<short, true>();
test<unsigned short, true>();
test<int, true>();
test<unsigned int, true>();
test<long, true>();
test<unsigned long, true>();
test<long long, true>();
test<unsigned long long, true>();
test<float, false>();
test<double, false>();
test<long double, false>();
}

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// is_iec559
#include <limits>
template <class T, bool expected>
void
test()
{
static_assert(std::numeric_limits<T>::is_iec559 == expected, "is_iec559 test 1");
static_assert(std::numeric_limits<const T>::is_iec559 == expected, "is_iec559 test 2");
static_assert(std::numeric_limits<volatile T>::is_iec559 == expected, "is_iec559 test 3");
static_assert(std::numeric_limits<const volatile T>::is_iec559 == expected, "is_iec559 test 4");
}
int main()
{
test<bool, false>();
test<char, false>();
test<signed char, false>();
test<unsigned char, false>();
test<wchar_t, false>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, false>();
test<char32_t, false>();
#endif
test<short, false>();
test<unsigned short, false>();
test<int, false>();
test<unsigned int, false>();
test<long, false>();
test<unsigned long, false>();
test<long long, false>();
test<unsigned long long, false>();
test<float, true>();
test<double, true>();
test<long double, true>();
}

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// is_integer
#include <limits>
template <class T, bool expected>
void
test()
{
static_assert(std::numeric_limits<T>::is_integer == expected, "is_integer test 1");
static_assert(std::numeric_limits<const T>::is_integer == expected, "is_integer test 2");
static_assert(std::numeric_limits<volatile T>::is_integer == expected, "is_integer test 3");
static_assert(std::numeric_limits<const volatile T>::is_integer == expected, "is_integer test 4");
}
int main()
{
test<bool, true>();
test<char, true>();
test<signed char, true>();
test<unsigned char, true>();
test<wchar_t, true>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, true>();
test<char32_t, true>();
#endif
test<short, true>();
test<unsigned short, true>();
test<int, true>();
test<unsigned int, true>();
test<long, true>();
test<unsigned long, true>();
test<long long, true>();
test<unsigned long long, true>();
test<float, false>();
test<double, false>();
test<long double, false>();
}

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// is_modulo
#include <limits>
template <class T, bool expected>
void
test()
{
static_assert(std::numeric_limits<T>::is_modulo == expected, "is_modulo test 1");
static_assert(std::numeric_limits<const T>::is_modulo == expected, "is_modulo test 2");
static_assert(std::numeric_limits<volatile T>::is_modulo == expected, "is_modulo test 3");
static_assert(std::numeric_limits<const volatile T>::is_modulo == expected, "is_modulo test 4");
}
int main()
{
test<bool, false>();
test<char, true>();
test<signed char, true>();
test<unsigned char, true>();
test<wchar_t, true>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, true>();
test<char32_t, true>();
#endif
test<short, true>();
test<unsigned short, true>();
test<int, true>();
test<unsigned int, true>();
test<long, true>();
test<unsigned long, true>();
test<long long, true>();
test<unsigned long long, true>();
test<float, false>();
test<double, false>();
test<long double, false>();
}

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// is_signed
#include <limits>
template <class T, bool expected>
void
test()
{
static_assert(std::numeric_limits<T>::is_signed == expected, "is_signed test 1");
static_assert(std::numeric_limits<const T>::is_signed == expected, "is_signed test 2");
static_assert(std::numeric_limits<volatile T>::is_signed == expected, "is_signed test 3");
static_assert(std::numeric_limits<const volatile T>::is_signed == expected, "is_signed test 4");
}
int main()
{
test<bool, false>();
test<char, char(-1) < char(0)>();
test<signed char, true>();
test<unsigned char, false>();
test<wchar_t, wchar_t(-1) < wchar_t(0)>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, false>();
test<char32_t, false>();
#endif
test<short, true>();
test<unsigned short, false>();
test<int, true>();
test<unsigned int, false>();
test<long, true>();
test<unsigned long, false>();
test<long long, true>();
test<unsigned long long, false>();
test<float, true>();
test<double, true>();
test<long double, true>();
}

View File

@@ -0,0 +1,56 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// lowest()
#include <limits>
#include <climits>
#include <cwchar>
#include <cfloat>
#include <cassert>
template <class T>
void
test(T expected)
{
assert(std::numeric_limits<T>::lowest() == expected);
assert(std::numeric_limits<T>::is_bounded);
assert(std::numeric_limits<const T>::lowest() == expected);
assert(std::numeric_limits<const T>::is_bounded);
assert(std::numeric_limits<volatile T>::lowest() == expected);
assert(std::numeric_limits<volatile T>::is_bounded);
assert(std::numeric_limits<const volatile T>::lowest() == expected);
assert(std::numeric_limits<const volatile T>::is_bounded);
}
int main()
{
test<bool>(false);
test<char>(CHAR_MIN);
test<signed char>(SCHAR_MIN);
test<unsigned char>(0);
test<wchar_t>(WCHAR_MIN);
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>(0);
test<char32_t>(0);
#endif
test<short>(SHRT_MIN);
test<unsigned short>(0);
test<int>(INT_MIN);
test<unsigned int>(0);
test<long>(LONG_MIN);
test<unsigned long>(0);
test<long long>(LLONG_MIN);
test<unsigned long long>(0);
test<float>(-FLT_MAX);
test<double>(-DBL_MAX);
test<long double>(-LDBL_MAX);
}

View File

@@ -0,0 +1,56 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// max()
#include <limits>
#include <climits>
#include <cwchar>
#include <cfloat>
#include <cassert>
template <class T>
void
test(T expected)
{
assert(std::numeric_limits<T>::max() == expected);
assert(std::numeric_limits<T>::is_bounded);
assert(std::numeric_limits<const T>::max() == expected);
assert(std::numeric_limits<const T>::is_bounded);
assert(std::numeric_limits<volatile T>::max() == expected);
assert(std::numeric_limits<volatile T>::is_bounded);
assert(std::numeric_limits<const volatile T>::max() == expected);
assert(std::numeric_limits<const volatile T>::is_bounded);
}
int main()
{
test<bool>(true);
test<char>(CHAR_MAX);
test<signed char>(SCHAR_MAX);
test<unsigned char>(UCHAR_MAX);
test<wchar_t>(WCHAR_MAX);
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>(USHRT_MAX);
test<char32_t>(UINT_MAX);
#endif
test<short>(SHRT_MAX);
test<unsigned short>(USHRT_MAX);
test<int>(INT_MAX);
test<unsigned int>(UINT_MAX);
test<long>(LONG_MAX);
test<unsigned long>(ULONG_MAX);
test<long long>(LLONG_MAX);
test<unsigned long long>(ULLONG_MAX);
test<float>(FLT_MAX);
test<double>(DBL_MAX);
test<long double>(LDBL_MAX);
}

View File

@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// max_digits10
#include <limits>
#include <cfloat>
template <class T, int expected>
void
test()
{
static_assert(std::numeric_limits<T>::max_digits10 == expected, "max_digits10 test 1");
static_assert(std::numeric_limits<const T>::max_digits10 == expected, "max_digits10 test 2");
static_assert(std::numeric_limits<volatile T>::max_digits10 == expected, "max_digits10 test 3");
static_assert(std::numeric_limits<const volatile T>::max_digits10 == expected, "max_digits10 test 4");
}
int main()
{
test<bool, 0>();
test<char, 0>();
test<signed char, 0>();
test<unsigned char, 0>();
test<wchar_t, 0>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, 0>();
test<char32_t, 0>();
#endif
test<short, 0>();
test<unsigned short, 0>();
test<int, 0>();
test<unsigned int, 0>();
test<long, 0>();
test<unsigned long, 0>();
test<long long, 0>();
test<unsigned long long, 0>();
test<float, 2+(FLT_MANT_DIG * 30103)/100000>();
test<double, 2+(DBL_MANT_DIG * 30103)/100000>();
test<long double, 2+(LDBL_MANT_DIG * 30103)/100000>();
}

View File

@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// max_exponent
#include <limits>
#include <cfloat>
template <class T, int expected>
void
test()
{
static_assert(std::numeric_limits<T>::max_exponent == expected, "max_exponent test 1");
static_assert(std::numeric_limits<const T>::max_exponent == expected, "max_exponent test 2");
static_assert(std::numeric_limits<volatile T>::max_exponent == expected, "max_exponent test 3");
static_assert(std::numeric_limits<const volatile T>::max_exponent == expected, "max_exponent test 4");
}
int main()
{
test<bool, 0>();
test<char, 0>();
test<signed char, 0>();
test<unsigned char, 0>();
test<wchar_t, 0>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, 0>();
test<char32_t, 0>();
#endif
test<short, 0>();
test<unsigned short, 0>();
test<int, 0>();
test<unsigned int, 0>();
test<long, 0>();
test<unsigned long, 0>();
test<long long, 0>();
test<unsigned long long, 0>();
test<float, FLT_MAX_EXP>();
test<double, DBL_MAX_EXP>();
test<long double, LDBL_MAX_EXP>();
}

View File

@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// max_exponent10
#include <limits>
#include <cfloat>
template <class T, int expected>
void
test()
{
static_assert(std::numeric_limits<T>::max_exponent10 == expected, "max_exponent10 test 1");
static_assert(std::numeric_limits<const T>::max_exponent10 == expected, "max_exponent10 test 2");
static_assert(std::numeric_limits<volatile T>::max_exponent10 == expected, "max_exponent10 test 3");
static_assert(std::numeric_limits<const volatile T>::max_exponent10 == expected, "max_exponent10 test 4");
}
int main()
{
test<bool, 0>();
test<char, 0>();
test<signed char, 0>();
test<unsigned char, 0>();
test<wchar_t, 0>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, 0>();
test<char32_t, 0>();
#endif
test<short, 0>();
test<unsigned short, 0>();
test<int, 0>();
test<unsigned int, 0>();
test<long, 0>();
test<unsigned long, 0>();
test<long long, 0>();
test<unsigned long long, 0>();
test<float, FLT_MAX_10_EXP>();
test<double, DBL_MAX_10_EXP>();
test<long double, LDBL_MAX_10_EXP>();
}

View File

@@ -0,0 +1,56 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// min()
#include <limits>
#include <climits>
#include <cwchar>
#include <cfloat>
#include <cassert>
template <class T>
void
test(T expected)
{
assert(std::numeric_limits<T>::min() == expected);
assert(std::numeric_limits<T>::is_bounded || !std::numeric_limits<T>::is_signed);
assert(std::numeric_limits<const T>::min() == expected);
assert(std::numeric_limits<const T>::is_bounded || !std::numeric_limits<const T>::is_signed);
assert(std::numeric_limits<volatile T>::min() == expected);
assert(std::numeric_limits<volatile T>::is_bounded || !std::numeric_limits<volatile T>::is_signed);
assert(std::numeric_limits<const volatile T>::min() == expected);
assert(std::numeric_limits<const volatile T>::is_bounded || !std::numeric_limits<const volatile T>::is_signed);
}
int main()
{
test<bool>(false);
test<char>(CHAR_MIN);
test<signed char>(SCHAR_MIN);
test<unsigned char>(0);
test<wchar_t>(WCHAR_MIN);
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>(0);
test<char32_t>(0);
#endif
test<short>(SHRT_MIN);
test<unsigned short>(0);
test<int>(INT_MIN);
test<unsigned int>(0);
test<long>(LONG_MIN);
test<unsigned long>(0);
test<long long>(LLONG_MIN);
test<unsigned long long>(0);
test<float>(FLT_MIN);
test<double>(DBL_MIN);
test<long double>(LDBL_MIN);
}

View File

@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// min_exponent
#include <limits>
#include <cfloat>
template <class T, int expected>
void
test()
{
static_assert(std::numeric_limits<T>::min_exponent == expected, "min_exponent test 1");
static_assert(std::numeric_limits<const T>::min_exponent == expected, "min_exponent test 2");
static_assert(std::numeric_limits<volatile T>::min_exponent == expected, "min_exponent test 3");
static_assert(std::numeric_limits<const volatile T>::min_exponent == expected, "min_exponent test 4");
}
int main()
{
test<bool, 0>();
test<char, 0>();
test<signed char, 0>();
test<unsigned char, 0>();
test<wchar_t, 0>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, 0>();
test<char32_t, 0>();
#endif
test<short, 0>();
test<unsigned short, 0>();
test<int, 0>();
test<unsigned int, 0>();
test<long, 0>();
test<unsigned long, 0>();
test<long long, 0>();
test<unsigned long long, 0>();
test<float, FLT_MIN_EXP>();
test<double, DBL_MIN_EXP>();
test<long double, LDBL_MIN_EXP>();
}

View File

@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// min_exponent10
#include <limits>
#include <cfloat>
template <class T, int expected>
void
test()
{
static_assert(std::numeric_limits<T>::min_exponent10 == expected, "min_exponent10 test 1");
static_assert(std::numeric_limits<const T>::min_exponent10 == expected, "min_exponent10 test 2");
static_assert(std::numeric_limits<volatile T>::min_exponent10 == expected, "min_exponent10 test 3");
static_assert(std::numeric_limits<const volatile T>::min_exponent10 == expected, "min_exponent10 test 4");
}
int main()
{
test<bool, 0>();
test<char, 0>();
test<signed char, 0>();
test<unsigned char, 0>();
test<wchar_t, 0>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, 0>();
test<char32_t, 0>();
#endif
test<short, 0>();
test<unsigned short, 0>();
test<int, 0>();
test<unsigned int, 0>();
test<long, 0>();
test<unsigned long, 0>();
test<long long, 0>();
test<unsigned long long, 0>();
test<float, FLT_MIN_10_EXP>();
test<double, DBL_MIN_10_EXP>();
test<long double, LDBL_MIN_10_EXP>();
}

View File

@@ -0,0 +1,69 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// quiet_NaN()
#include <limits>
#include <cmath>
#include <type_traits>
#include <cassert>
template <class T>
void
test_imp(std::true_type)
{
assert(std::isnan(std::numeric_limits<T>::quiet_NaN()));
assert(std::isnan(std::numeric_limits<const T>::quiet_NaN()));
assert(std::isnan(std::numeric_limits<volatile T>::quiet_NaN()));
assert(std::isnan(std::numeric_limits<const volatile T>::quiet_NaN()));
}
template <class T>
void
test_imp(std::false_type)
{
assert(std::numeric_limits<T>::quiet_NaN() == T());
assert(std::numeric_limits<const T>::quiet_NaN() == T());
assert(std::numeric_limits<volatile T>::quiet_NaN() == T());
assert(std::numeric_limits<const volatile T>::quiet_NaN() == T());
}
template <class T>
inline
void
test()
{
test_imp<T>(std::is_floating_point<T>());
}
int main()
{
test<bool>();
test<char>();
test<signed char>();
test<unsigned char>();
test<wchar_t>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();
#endif
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
test<long long>();
test<unsigned long long>();
test<float>();
test<double>();
test<long double>();
}

View File

@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// radix
#include <limits>
#include <cfloat>
template <class T, int expected>
void
test()
{
static_assert(std::numeric_limits<T>::radix == expected, "radix test 1");
static_assert(std::numeric_limits<const T>::radix == expected, "radix test 2");
static_assert(std::numeric_limits<volatile T>::radix == expected, "radix test 3");
static_assert(std::numeric_limits<const volatile T>::radix == expected, "radix test 4");
}
int main()
{
test<bool, 2>();
test<char, 2>();
test<signed char, 2>();
test<unsigned char, 2>();
test<wchar_t, 2>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, 2>();
test<char32_t, 2>();
#endif
test<short, 2>();
test<unsigned short, 2>();
test<int, 2>();
test<unsigned int, 2>();
test<long, 2>();
test<unsigned long, 2>();
test<long long, 2>();
test<unsigned long long, 2>();
test<float, FLT_RADIX>();
test<double, FLT_RADIX>();
test<long double, FLT_RADIX>();
}

View File

@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// round_error()
#include <limits>
#include <cfloat>
#include <cassert>
template <class T>
void
test(T expected)
{
assert(std::numeric_limits<T>::round_error() == expected);
assert(std::numeric_limits<const T>::round_error() == expected);
assert(std::numeric_limits<volatile T>::round_error() == expected);
assert(std::numeric_limits<const volatile T>::round_error() == expected);
}
int main()
{
test<bool>(false);
test<char>(0);
test<signed char>(0);
test<unsigned char>(0);
test<wchar_t>(0);
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>(0);
test<char32_t>(0);
#endif
test<short>(0);
test<unsigned short>(0);
test<int>(0);
test<unsigned int>(0);
test<long>(0);
test<unsigned long>(0);
test<long long>(0);
test<unsigned long long>(0);
test<float>(0.5);
test<double>(0.5);
test<long double>(0.5);
}

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// round_style
#include <limits>
template <class T, std::float_round_style expected>
void
test()
{
static_assert(std::numeric_limits<T>::round_style == expected, "round_style test 1");
static_assert(std::numeric_limits<const T>::round_style == expected, "round_style test 2");
static_assert(std::numeric_limits<volatile T>::round_style == expected, "round_style test 3");
static_assert(std::numeric_limits<const volatile T>::round_style == expected, "round_style test 4");
}
int main()
{
test<bool, std::round_toward_zero>();
test<char, std::round_toward_zero>();
test<signed char, std::round_toward_zero>();
test<unsigned char, std::round_toward_zero>();
test<wchar_t, std::round_toward_zero>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, std::round_toward_zero>();
test<char32_t, std::round_toward_zero>();
#endif
test<short, std::round_toward_zero>();
test<unsigned short, std::round_toward_zero>();
test<int, std::round_toward_zero>();
test<unsigned int, std::round_toward_zero>();
test<long, std::round_toward_zero>();
test<unsigned long, std::round_toward_zero>();
test<long long, std::round_toward_zero>();
test<unsigned long long, std::round_toward_zero>();
test<float, std::round_to_nearest>();
test<double, std::round_to_nearest>();
test<long double, std::round_to_nearest>();
}

View File

@@ -0,0 +1,69 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// signaling_NaN()
#include <limits>
#include <cmath>
#include <type_traits>
#include <cassert>
template <class T>
void
test_imp(std::true_type)
{
assert(std::isnan(std::numeric_limits<T>::signaling_NaN()));
assert(std::isnan(std::numeric_limits<const T>::signaling_NaN()));
assert(std::isnan(std::numeric_limits<volatile T>::signaling_NaN()));
assert(std::isnan(std::numeric_limits<const volatile T>::signaling_NaN()));
}
template <class T>
void
test_imp(std::false_type)
{
assert(std::numeric_limits<T>::signaling_NaN() == T());
assert(std::numeric_limits<const T>::signaling_NaN() == T());
assert(std::numeric_limits<volatile T>::signaling_NaN() == T());
assert(std::numeric_limits<const volatile T>::signaling_NaN() == T());
}
template <class T>
inline
void
test()
{
test_imp<T>(std::is_floating_point<T>());
}
int main()
{
test<bool>();
test<char>();
test<signed char>();
test<unsigned char>();
test<wchar_t>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();
#endif
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
test<long long>();
test<unsigned long long>();
test<float>();
test<double>();
test<long double>();
}

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// tinyness_before
#include <limits>
template <class T, bool expected>
void
test()
{
static_assert(std::numeric_limits<T>::tinyness_before == expected, "tinyness_before test 1");
static_assert(std::numeric_limits<const T>::tinyness_before == expected, "tinyness_before test 2");
static_assert(std::numeric_limits<volatile T>::tinyness_before == expected, "tinyness_before test 3");
static_assert(std::numeric_limits<const volatile T>::tinyness_before == expected, "tinyness_before test 4");
}
int main()
{
test<bool, false>();
test<char, false>();
test<signed char, false>();
test<unsigned char, false>();
test<wchar_t, false>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, false>();
test<char32_t, false>();
#endif
test<short, false>();
test<unsigned short, false>();
test<int, false>();
test<unsigned int, false>();
test<long, false>();
test<unsigned long, false>();
test<long long, false>();
test<unsigned long long, false>();
test<float, false>();
test<double, false>();
test<long double, false>();
}

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test numeric_limits
// traps
#include <limits>
template <class T, bool expected>
void
test()
{
static_assert(std::numeric_limits<T>::traps == expected, "traps test 1");
static_assert(std::numeric_limits<const T>::traps == expected, "traps test 2");
static_assert(std::numeric_limits<volatile T>::traps == expected, "traps test 3");
static_assert(std::numeric_limits<const volatile T>::traps == expected, "traps test 4");
}
int main()
{
test<bool, false>();
test<char, true>();
test<signed char, true>();
test<unsigned char, true>();
test<wchar_t, true>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, true>();
test<char32_t, true>();
#endif
test<short, true>();
test<unsigned short, true>();
test<int, true>();
test<unsigned int, true>();
test<long, true>();
test<unsigned long, true>();
test<long long, true>();
test<unsigned long long, true>();
test<float, false>();
test<double, false>();
test<long double, false>();
}