Skip to content

Commit 3ada7ca

Browse files
authored
Merge pull request #187 from fastfloat/dlemire/enable_tests_automatically
If we detect that the compiler supports FASTFLOAT_IS_CONSTEXPR, then let us run the tests automatically.
2 parents ab6c987 + a662df8 commit 3ada7ca

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fast_float_add_cpp_test(rcppfastfloat_test)
6060
fast_float_add_cpp_test(example_test)
6161
fast_float_add_cpp_test(example_comma_test)
6262
fast_float_add_cpp_test(basictest)
63-
option(FASTFLOAT_CONSTEXPR_TESTS "Constexpr tests" OFF)
63+
option(FASTFLOAT_CONSTEXPR_TESTS "Require constexpr tests (build will fail if the compiler won't support it)" OFF)
6464
if (FASTFLOAT_CONSTEXPR_TESTS)
6565
target_compile_features(basictest PRIVATE cxx_std_20)
6666
target_compile_definitions(basictest PRIVATE FASTFLOAT_CONSTEXPR_TESTS)

tests/basictest.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
#include <type_traits>
1414
#include <cfenv>
1515

16+
#if FASTFLOAT_IS_CONSTEXPR
17+
#ifndef FASTFLOAT_CONSTEXPR_TESTS
18+
#define FASTFLOAT_CONSTEXPR_TESTS 1
19+
#endif // #ifndef FASTFLOAT_CONSTEXPR_TESTS
20+
#endif // FASTFLOAT_IS_CONSTEXPR
21+
1622
#if FASTFLOAT_HAS_BIT_CAST
1723
#include <bit>
1824
#endif
@@ -74,6 +80,10 @@ const char * round_name(int d) {
7480

7581
TEST_CASE("system_info") {
7682
std::cout << "system info:" << std::endl;
83+
#ifdef FASTFLOAT_CONSTEXPR_TESTS
84+
SHOW_DEFINE(FASTFLOAT_CONSTEXPR_TESTS);
85+
86+
#endif
7787
#ifdef _MSC_VER
7888
SHOW_DEFINE(_MSC_VER);
7989
#endif

0 commit comments

Comments
 (0)