Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add failing test for JSON roundtrip precision loss #731

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.fasterxml.jackson.core.json;

import com.fasterxml.jackson.core.BaseTest;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;

import java.io.ByteArrayOutputStream;
import java.io.StringWriter;

public class JsonParserGeneratorTest
extends BaseTest {
final JsonFactory JSON_F = newStreamFactory();

public void testRoundtripBigDecimal() throws Exception {
String input = "1e999";
JsonParser parser = JSON_F.createParser(input);
parser.nextToken();
StringWriter stringWriter = new StringWriter();
JsonGenerator generator = JSON_F.createGenerator(stringWriter);
generator.copyCurrentEvent(parser);
parser.close();
generator.close();
String actual = stringWriter.toString(); // "Infinity"
assertEquals(input, actual);
}
}