@@ -16,7 +16,7 @@ BOOST_AUTO_TEST_CASE(number_truncating)
1616
1717 // this number would have more than 10 decimals if not truncated
1818 renderer (Number{42.9995999594999399299 });
19- BOOST_CHECK_EQUAL (str, " 42.999599959 " );
19+ BOOST_CHECK_EQUAL (str, " 42.99959996 " );
2020}
2121
2222BOOST_AUTO_TEST_CASE (integer)
@@ -27,4 +27,68 @@ BOOST_AUTO_TEST_CASE(integer)
2727 BOOST_CHECK_EQUAL (str, " 42" );
2828}
2929
30+ BOOST_AUTO_TEST_CASE (test_json_issue_6531)
31+ {
32+ std::string output;
33+ osrm::util::json::Renderer<std::string> renderer (output);
34+ renderer (0.0000000000017114087924596788 );
35+ BOOST_CHECK_EQUAL (output, " 1.711408792e-12" );
36+
37+ output.clear ();
38+ renderer (42.0 );
39+ BOOST_CHECK_EQUAL (output, " 42" );
40+
41+ output.clear ();
42+ renderer (42.1 );
43+ BOOST_CHECK_EQUAL (output, " 42.1" );
44+
45+ output.clear ();
46+ renderer (42.12 );
47+ BOOST_CHECK_EQUAL (output, " 42.12" );
48+
49+ output.clear ();
50+ renderer (42.123 );
51+ BOOST_CHECK_EQUAL (output, " 42.123" );
52+
53+ output.clear ();
54+ renderer (42.1234 );
55+ BOOST_CHECK_EQUAL (output, " 42.1234" );
56+
57+ output.clear ();
58+ renderer (42.12345 );
59+ BOOST_CHECK_EQUAL (output, " 42.12345" );
60+
61+ output.clear ();
62+ renderer (42.123456 );
63+ BOOST_CHECK_EQUAL (output, " 42.123456" );
64+
65+ output.clear ();
66+ renderer (42.1234567 );
67+ BOOST_CHECK_EQUAL (output, " 42.1234567" );
68+
69+ output.clear ();
70+ renderer (42.12345678 );
71+ BOOST_CHECK_EQUAL (output, " 42.12345678" );
72+
73+ output.clear ();
74+ renderer (42.123456789 );
75+ BOOST_CHECK_EQUAL (output, " 42.12345679" );
76+
77+ output.clear ();
78+ renderer (0.12345678912345 );
79+ BOOST_CHECK_EQUAL (output, " 0.1234567891" );
80+
81+ output.clear ();
82+ renderer (0.123456789 );
83+ BOOST_CHECK_EQUAL (output, " 0.123456789" );
84+
85+ output.clear ();
86+ renderer (0.12345678916 );
87+ BOOST_CHECK_EQUAL (output, " 0.1234567892" );
88+
89+ output.clear ();
90+ renderer (123456789123456789 );
91+ BOOST_CHECK_EQUAL (output, " 1.234567891e+17" );
92+ }
93+
3094BOOST_AUTO_TEST_SUITE_END ()
0 commit comments