Skip to content

Commit

Permalink
🐛 make SAX output locale-independent #4084
Browse files Browse the repository at this point in the history
  • Loading branch information
nlohmann committed Nov 22, 2024
1 parent 8cc880f commit d4a06db
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ jobs:
- name: Build
run: cmake --build build --target ci_test_coverage
- name: Archive coverage report
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: ${{ github.workspace }}/build/html
Expand Down
14 changes: 14 additions & 0 deletions tests/src/unit-locale-cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ TEST_CASE("locale-dependent test (LC_NUMERIC=C")
{
WARN_MESSAGE(std::setlocale(LC_NUMERIC, "C") != nullptr, "could not set locale");

SECTION("check if locale is properly set")
{
std::array<char, 6> buffer = {};
CHECK(std::snprintf(buffer.data(), buffer.size(), "%.2f", 12.34) == 5);
CHECK(std::string(buffer.data()) == "12.34");
}

SECTION("parsing")
{
CHECK(json::parse("12.34").dump() == "12.34");
Expand All @@ -128,6 +135,13 @@ TEST_CASE("locale-dependent test (LC_NUMERIC=de_DE")
{
WARN_MESSAGE(std::setlocale(LC_NUMERIC, "de_DE") != nullptr, "could not set locale");

SECTION("check if locale is properly set")
{
std::array<char, 6> buffer = {};
CHECK(std::snprintf(buffer.data(), buffer.size(), "%.2f", 12.34) == 5);
CHECK(std::string(buffer.data()) == "12,34");
}

SECTION("parsing")
{
CHECK(json::parse("12.34").dump() == "12.34");
Expand Down
2 changes: 1 addition & 1 deletion tests/thirdparty/doctest/doctest.h
Original file line number Diff line number Diff line change
Expand Up @@ -5493,7 +5493,7 @@ namespace {
.writeAttribute("testsuite", in.data[i]->m_test_suite)
.writeAttribute("filename", skipPathFromFilename(in.data[i]->m_file.c_str()))
.writeAttribute("line", line(in.data[i]->m_line))
.writeAttribute("skipped", in.data[i]->m_skip);
.writeAttribute("Dped", in.data[i]->m_skip);
}
xml.scopedElement("OverallResultsTestCases")
.writeAttribute("unskipped", in.run_stats->numTestCasesPassingFilters);
Expand Down

0 comments on commit d4a06db

Please sign in to comment.