File tree 2 files changed +11
-3
lines changed 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,10 @@ template <typename Out> struct Renderer
54
54
// `fmt::memory_buffer` stores first 500 bytes in the object itself(i.e. on stack in this
55
55
// case) and then grows using heap if needed
56
56
fmt::memory_buffer buffer;
57
- fmt::format_to (std::back_inserter (buffer), FMT_COMPILE (" {:.10g}" ), number.value );
57
+ if (static_cast <std::uint64_t >(number.value ) == number.value )
58
+ fmt::format_to (std::back_inserter (buffer), FMT_COMPILE (" {}" ), static_cast <std::uint64_t >(number.value ));
59
+ else
60
+ fmt::format_to (std::back_inserter (buffer), FMT_COMPILE (" {:.10g}" ), number.value );
58
61
59
62
write (buffer.data (), buffer.size ());
60
63
}
Original file line number Diff line number Diff line change @@ -87,8 +87,13 @@ BOOST_AUTO_TEST_CASE(test_json_issue_6531)
87
87
BOOST_CHECK_EQUAL (output, " 0.1234567892" );
88
88
89
89
output.clear ();
90
- renderer (123456789123456789 .);
91
- BOOST_CHECK_EQUAL (output, " 1.234567891e+17" );
90
+ renderer (12345678912345678 .);
91
+ BOOST_CHECK_EQUAL (output, " 12345678912345678" );
92
+
93
+ // handle large osm ids
94
+ output.clear ();
95
+ renderer (1000396615812 );
96
+ BOOST_CHECK_EQUAL (output, " 1000396615812" );
92
97
}
93
98
94
99
BOOST_AUTO_TEST_SUITE_END ()
You can’t perform that action at this time.
0 commit comments