mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-26 02:14:22 +00:00
Serialise doubles into more human friendly XML and JSON
This commit is contained in:
parent
77db5fde66
commit
bbe49f6b36
6 changed files with 124 additions and 17 deletions
|
|
@ -352,8 +352,7 @@ struct JSONFormatter
|
|||
|
||||
if (juce_isfinite (d))
|
||||
{
|
||||
String doubleString (d, maximumDecimalPlaces, true);
|
||||
out << minimiseLengthOfFloatString (doubleString);
|
||||
out << serialiseDouble (d);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -664,12 +663,17 @@ public:
|
|||
tests[1] = "1";
|
||||
tests[1.1] = "1.1";
|
||||
tests[1.01] = "1.01";
|
||||
tests[0.76378] = "7.6378e-1";
|
||||
tests[-10] = "-1e1";
|
||||
tests[10.01] = "1.001e1";
|
||||
tests[0.0123] = "1.23e-2";
|
||||
tests[0.76378] = "0.76378";
|
||||
tests[-10] = "-10";
|
||||
tests[10.01] = "10.01";
|
||||
tests[0.0123] = "0.0123";
|
||||
tests[-3.7e-27] = "-3.7e-27";
|
||||
tests[1e+40] = "1e40";
|
||||
tests[-12345678901234567.0] = "-1.234567890123457e16";
|
||||
tests[192000] = "192000";
|
||||
tests[1234567] = "1.234567e6";
|
||||
tests[0.00006] = "0.00006";
|
||||
tests[0.000006] = "6e-6";
|
||||
|
||||
for (auto& test : tests)
|
||||
expectEquals (JSON::toString (test.first), test.second);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue