[libcxx] [test] D26812: In random tests, use real static_asserts and silence a warning.

In C++11 mode and newer, use real static_asserts.
In C++03 mode, min() and max() aren't constexpr, so use plain asserts.

One test triggers MSVC's warning C4310 "cast truncates constant value".
The code is valid, and yet the warning is valid, so I'm silencing it
through push-disable-pop.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@287391 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Stephan T. Lavavej
2016-11-18 22:45:32 +00:00
parent c044b03d26
commit 2917004aed
6 changed files with 84 additions and 20 deletions

View File

@@ -37,8 +37,27 @@ test1()
static_assert((LCE::multiplier == a), "");
static_assert((LCE::increment == c), "");
static_assert((LCE::modulus == m), "");
/*static_*/assert((LCE::min() == (c == 0u ? 1u: 0u))/*, ""*/);
/*static_*/assert((LCE::max() == result_type(m - 1u))/*, ""*/);
#if TEST_STD_VER >= 11
static_assert((LCE::min() == (c == 0u ? 1u: 0u)), "");
#else
assert((LCE::min() == (c == 0u ? 1u: 0u)));
#endif
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4310) // cast truncates constant value
#endif // _MSC_VER
#if TEST_STD_VER >= 11
static_assert((LCE::max() == result_type(m - 1u)), "");
#else
assert((LCE::max() == result_type(m - 1u)));
#endif
#ifdef _MSC_VER
#pragma warning(pop)
#endif // _MSC_VER
static_assert((LCE::default_seed == 1), "");
where(LCE::multiplier);
where(LCE::increment);