Skip to content

Commit b8f0afd

Browse files
committed
Fix compilation with libc++ < 20.
1 parent 8f4cf06 commit b8f0afd

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

tests/test_csv_util.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,17 @@ TEST_CASE("CsvUtilities", "[csv][util]")
8888

8989

9090
SECTION("readNumberNoLocale() performs as expected") {
91-
// Most of these tests are done in parser test above.
92-
REQUIRE_FALSE(Csv::readNumberNoLocale<double>(""sv).has_value());
93-
REQUIRE_FALSE(Csv::readNumberNoLocale<double>("a5"sv).has_value());
94-
REQUIRE_FALSE(Csv::readNumberNoLocale<double>("5a"sv).has_value());
95-
REQUIRE_FALSE(Csv::readNumberNoLocale<double>("5 a"sv).has_value());
96-
REQUIRE(Csv::readNumberNoLocale<double>("1"sv) == 1.);
97-
REQUIRE(Csv::readNumberNoLocale<double>("-5e+6"sv) == -5e+6);
98-
REQUIRE(Csv::readNumberNoLocale<double>("-Inf"sv) == -std::numeric_limits<double>::infinity());
99-
REQUIRE(std::isnan(Csv::readNumberNoLocale<double>("nan"sv).value()));
91+
// When using libc++, std::from_chars supports floating point starting from v20.
92+
#if !defined _LIBCPP_VERSION || _LIBCPP_VERSION > 200000
93+
REQUIRE_FALSE(Csv::readNumberNoLocale<double>(""sv).has_value());
94+
REQUIRE_FALSE(Csv::readNumberNoLocale<double>("a5"sv).has_value());
95+
REQUIRE_FALSE(Csv::readNumberNoLocale<double>("5a"sv).has_value());
96+
REQUIRE_FALSE(Csv::readNumberNoLocale<double>("5 a"sv).has_value());
97+
REQUIRE(Csv::readNumberNoLocale<double>("1"sv) == 1.);
98+
REQUIRE(Csv::readNumberNoLocale<double>("-5e+6"sv) == -5e+6);
99+
REQUIRE(Csv::readNumberNoLocale<double>("-Inf"sv) == -std::numeric_limits<double>::infinity());
100+
REQUIRE(std::isnan(Csv::readNumberNoLocale<double>("nan"sv).value()));
101+
#endif
100102

101103
REQUIRE_FALSE(Csv::readNumberNoLocale<int>(""sv).has_value());
102104
REQUIRE_FALSE(Csv::readNumberNoLocale<int>("a5"sv).has_value());

0 commit comments

Comments
 (0)