If we detect that the compiler supports FASTFLOAT_IS_CONSTEXPR, then let us run the tests automatically.

This commit is contained in:
Daniel Lemire 2023-03-26 20:43:33 -04:00
parent ab6c987ebc
commit a662df817f
2 changed files with 11 additions and 1 deletions

View File

@ -60,7 +60,7 @@ fast_float_add_cpp_test(rcppfastfloat_test)
fast_float_add_cpp_test(example_test) fast_float_add_cpp_test(example_test)
fast_float_add_cpp_test(example_comma_test) fast_float_add_cpp_test(example_comma_test)
fast_float_add_cpp_test(basictest) fast_float_add_cpp_test(basictest)
option(FASTFLOAT_CONSTEXPR_TESTS "Constexpr tests" OFF) option(FASTFLOAT_CONSTEXPR_TESTS "Require constexpr tests (build will fail if the compiler won't support it)" OFF)
if (FASTFLOAT_CONSTEXPR_TESTS) if (FASTFLOAT_CONSTEXPR_TESTS)
target_compile_features(basictest PRIVATE cxx_std_20) target_compile_features(basictest PRIVATE cxx_std_20)
target_compile_definitions(basictest PRIVATE FASTFLOAT_CONSTEXPR_TESTS) target_compile_definitions(basictest PRIVATE FASTFLOAT_CONSTEXPR_TESTS)

View File

@ -13,6 +13,12 @@
#include <type_traits> #include <type_traits>
#include <cfenv> #include <cfenv>
#if FASTFLOAT_IS_CONSTEXPR
#ifndef FASTFLOAT_CONSTEXPR_TESTS
#define FASTFLOAT_CONSTEXPR_TESTS 1
#endif // #ifndef FASTFLOAT_CONSTEXPR_TESTS
#endif // FASTFLOAT_IS_CONSTEXPR
#if FASTFLOAT_HAS_BIT_CAST #if FASTFLOAT_HAS_BIT_CAST
#include <bit> #include <bit>
#endif #endif
@ -74,6 +80,10 @@ const char * round_name(int d) {
TEST_CASE("system_info") { TEST_CASE("system_info") {
std::cout << "system info:" << std::endl; std::cout << "system info:" << std::endl;
#ifdef FASTFLOAT_CONSTEXPR_TESTS
SHOW_DEFINE(FASTFLOAT_CONSTEXPR_TESTS);
#endif
#ifdef _MSC_VER #ifdef _MSC_VER
SHOW_DEFINE(_MSC_VER); SHOW_DEFINE(_MSC_VER);
#endif #endif