diff options
| author | Martin Hořeňovský | 2026-07-23 00:10:23 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2026-07-23 00:10:28 +0200 |
| commit | 0cc833ea95bb7136c99be1b5b105780cae5766ff (patch) | |
| tree | 79c0041f474ea251045ed6ccfe1daabd0a5dc13e /src/catch2/internal/catch_jsonwriter.cpp | |
| parent | 8494e2dce47d944d52f497722272256dc8b2e626 (diff) | |
| download | catch3-0cc833ea95bb7136c99be1b5b105780cae5766ff.tar.gz | |
Make JSONWriter's number handling locale-independent
Closes #3176
Diffstat (limited to 'src/catch2/internal/catch_jsonwriter.cpp')
| -rw-r--r-- | src/catch2/internal/catch_jsonwriter.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/catch2/internal/catch_jsonwriter.cpp b/src/catch2/internal/catch_jsonwriter.cpp index 6915c9c3..6a994f11 100644 --- a/src/catch2/internal/catch_jsonwriter.cpp +++ b/src/catch2/internal/catch_jsonwriter.cpp @@ -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 }; |