mirror of
https://github.com/Tencent/rapidjson.git
synced 2025-10-27 02:53:13 +01:00
Remove double precision settings API in Writer
This commit is contained in:
@@ -65,62 +65,6 @@ TEST(Writer, Double) {
|
||||
|
||||
}
|
||||
|
||||
//TEST(Writer,DoublePrecision) {
|
||||
// const char json[] = "[1.2345,1.2345678,0.123456789012,1234567.8]";
|
||||
//
|
||||
// StringBuffer buffer;
|
||||
// Writer<StringBuffer> writer(buffer);
|
||||
//
|
||||
// const int kDefaultDoublePrecision = 6;
|
||||
// // handling the double precision
|
||||
// EXPECT_EQ(writer.GetDoublePrecision(), kDefaultDoublePrecision);
|
||||
// writer.SetDoublePrecision(17);
|
||||
// EXPECT_EQ(writer.GetDoublePrecision(), 17);
|
||||
// writer.SetDoublePrecision(-1); // negative equivalent to reset
|
||||
// EXPECT_EQ(writer.GetDoublePrecision(), kDefaultDoublePrecision);
|
||||
// writer.SetDoublePrecision(1);
|
||||
// writer.SetDoublePrecision(); // reset again
|
||||
// EXPECT_EQ(writer.GetDoublePrecision(), kDefaultDoublePrecision);
|
||||
//
|
||||
// { // write with explicitly increased precision
|
||||
// StringStream s(json);
|
||||
// Reader reader;
|
||||
// reader.Parse<0>(s, writer.SetDoublePrecision(12));
|
||||
// EXPECT_EQ(writer.GetDoublePrecision(), 12);
|
||||
// EXPECT_STREQ(json, buffer.GetString());
|
||||
// }
|
||||
// { // explicit individual double precisions
|
||||
// buffer.Clear();
|
||||
// writer.Reset(buffer);
|
||||
// writer.SetDoublePrecision(2);
|
||||
// writer.StartArray();
|
||||
// writer.Double(1.2345, 5);
|
||||
// writer.Double(1.2345678, 9);
|
||||
// writer.Double(0.123456789012, 12);
|
||||
// writer.Double(1234567.8, 8);
|
||||
// writer.EndArray();
|
||||
//
|
||||
// EXPECT_EQ(writer.GetDoublePrecision(), 2);
|
||||
// EXPECT_STREQ(json, buffer.GetString());
|
||||
// }
|
||||
// { // write with default precision (output with precision loss)
|
||||
// Document d;
|
||||
// d.Parse<0>(json);
|
||||
// buffer.Clear();
|
||||
// writer.Reset(buffer);
|
||||
// d.Accept(writer.SetDoublePrecision());
|
||||
//
|
||||
// // parsed again to avoid platform-dependent floating point outputs
|
||||
// // (e.g. width of exponents)
|
||||
// d.Parse<0>(buffer.GetString());
|
||||
// EXPECT_EQ(writer.GetDoublePrecision(), kDefaultDoublePrecision);
|
||||
// EXPECT_DOUBLE_EQ(d[0u].GetDouble(), 1.2345);
|
||||
// EXPECT_DOUBLE_EQ(d[1u].GetDouble(), 1.23457);
|
||||
// EXPECT_DOUBLE_EQ(d[2u].GetDouble(), 0.123457);
|
||||
// EXPECT_DOUBLE_EQ(d[3u].GetDouble(), 1234570);
|
||||
// }
|
||||
//}
|
||||
|
||||
TEST(Writer, Transcode) {
|
||||
const char json[] = "{\"hello\":\"world\",\"t\":true,\"f\":false,\"n\":null,\"i\":123,\"pi\":3.1416,\"a\":[1,2,3],\"dollar\":\"\x24\",\"cents\":\"\xC2\xA2\",\"euro\":\"\xE2\x82\xAC\",\"gclef\":\"\xF0\x9D\x84\x9E\"}";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user