From 1c029b97c0ebc90b5b7f1cb875b0904f115668b8 Mon Sep 17 00:00:00 2001 From: Alex Astashyn Date: Thu, 8 Dec 2016 22:13:05 -0500 Subject: [PATCH] Still trying to invoke locale-specific behavior in CI --- test/src/unit-regression.cpp | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index deace862..5cd6356d 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -405,46 +405,21 @@ TEST_CASE("regression tests") SECTION("issue #379 - locale-independent str-to-num") { - // If I save the locale here and restore it in the end - // of this block, then setLocale(LC_NUMERIC, "de_DE") - // does not actually make snprintf use "," as decimal separator - // on some compilers. I have no idea... - //const std::string orig_locale_name(setlocale(LC_ALL, NULL)); - - - // Still, just setting some comma-using locale does not - // make snprintf output commas on all platforms, so instead - // will change dot to comma in the current locale below - //setlocale(LC_NUMERIC, "de_DE"); - - auto loc = localeconv(); - auto orig_decimal_point = loc->decimal_point; - char comma[] = ","; - loc->decimal_point = comma; - - std::array buf; + setlocale(LC_NUMERIC, "de_DE.UTF-8"); { // verify that strtod now uses commas as decimal-separator - const double d1 = std::strtod("3,14", nullptr); - CHECK(d1 == 3.14); + CHECK(std::strtod("3,14", nullptr) == 3.14); // verify that strtod does not understand dots as decimal separator - const double d2 = std::strtod("3.14", nullptr); - CHECK(d2 == 3); + CHECK(std::strtod("3.14", nullptr) == 3); } // verify that parsed correctly despite using strtod internally - const json j1 = json::parse("3.14"); - CHECK(j1.get() == 3.14); + CHECK(json::parse("3.14").get() == 3.14); // check a different code path - const json j2 = json::parse("1.000000000000000000000000000000000000000000000000000000000000000000000000"); - CHECK(j2.get() == 1.0); - - loc->decimal_point = orig_decimal_point; - // restore original locale - // setlocale(LC_ALL, orig_locale_name.c_str()); + CHECK(json::parse("1.000000000000000000000000000000000000000000000000000000000000000000000000").get() == 1.0); }