Make JSONWriter's number handling locale-independent

Closes #3176
This commit is contained in:
Martin Hořeňovský
2026-07-23 00:10:28 +02:00
parent 8494e2dce4
commit 0cc833ea95
19 changed files with 211 additions and 19 deletions
+6 -1
View File
@@ -9,6 +9,8 @@
#include <catch2/internal/catch_jsonwriter.hpp>
#include <catch2/internal/catch_unreachable.hpp>
#include <locale>
namespace Catch {
namespace {
@@ -126,7 +128,10 @@ namespace Catch {
JsonValueWriter::JsonValueWriter( std::ostream& os,
std::uint64_t indent_level ):
m_os{ os }, m_indent_level{ indent_level } {}
m_os{ os }, m_indent_level{ indent_level } {
// We use C locale so that writing of numerical values is locale-independent.
m_sstream.imbue( std::locale::classic() );
}
JsonObjectWriter JsonValueWriter::writeObject() && {
return JsonObjectWriter{ m_os, m_indent_level };