Commit d2e9ce27 authored by Alex Astashyn's avatar Alex Astashyn

Trying to coerce setlocale to make snprintf use commas as delimiter; the...

Trying to coerce setlocale to make snprintf use commas as delimiter; the behavior appears to be compiler/platform-specific
parent 6e8da7d8
......@@ -407,21 +407,21 @@ TEST_CASE("regression tests")
{
const std::string orig_locale_name(setlocale(LC_ALL, NULL));
setlocale(LC_NUMERIC, "de_DE");
setlocale(LC_NUMERIC, "fr_Fr.UTF-8");
std::array<char, 64> buf;
{
// verify that snprintf now uses commas as decimal-separator
std::snprintf(buf.data(), buf.size(), "%.2f", 3.14);
assert(std::strcmp(buf.data(), "3,14") == 0);
CHECK(std::strcmp(buf.data(), "3,14") == 0);
// verify that strtod now uses commas as decimal-separator
const double d1 = std::strtod(buf.data(), nullptr);
assert(d1 == 3.14);
CHECK(d1 == 3.14);
// verify that strtod does not understand dots as decimal separator
const double d2 = std::strtod("3.14", nullptr);
assert(d2 == 3);
CHECK(d2 == 3);
}
const json j1 = json::parse("3.14");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment