Skip to content

Commit

Permalink
get tests working with 2.14 code
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning authored and cowtowncoder committed Sep 26, 2023
1 parent 98b61ba commit f7eeba6
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

import org.json.*;

import java.math.BigDecimal;

public class SimpleReadTest extends ModuleTestBase
{
public void testReadObject() throws Exception
Expand Down Expand Up @@ -54,25 +52,5 @@ public void testDouble() throws Exception

JSONObject val = mapper.readValue("{\"val\":0.5}", JSONObject.class);
assertEquals(0.5d, val.getDouble("val"));
assertEquals(new BigDecimal(0.5d), val.get("val"));
}

public void testBigInteger() throws Exception
{
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JsonOrgModule());

JSONObject val = mapper.readValue("{\"val\":2e308}", JSONObject.class);
assertEquals(new BigDecimal("2e308").toBigInteger(), val.getBigInteger("val"));
}

public void testBigIntegerArray() throws Exception
{
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JsonOrgModule());

JSONArray array = mapper.readValue("[2e308]", JSONArray.class);
assertEquals(1, array.length());
assertEquals(new BigDecimal("2e308").toBigInteger(), array.getBigInteger(0));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,25 +137,6 @@ public void testConstructorProperties() throws Exception
assertSame(JsonValue.NULL, ob2.obj2);
}

public void testBigInteger() throws Exception
{
final String JSON = "[2e308]";
JsonValue v = MAPPER.readValue(JSON, JsonValue.class);
assertTrue(v instanceof JsonArray);
JsonArray a = (JsonArray) v;
assertEquals(1, a.size());
assertTrue(a.get(0) instanceof JsonNumber);
assertEquals(new BigDecimal("2e308").toBigInteger(), ((JsonNumber) a.get(0)).bigIntegerValue());


// also, should work with explicit type
JsonArray array = MAPPER.readValue(JSON, JsonArray.class);
assertEquals(1, array.size());

// and round-tripping ought to be ok:
assertEquals("[2E+308]", serializeAsString(v));
}

public void testDouble() throws Exception
{
JsonValue val = MAPPER.readValue("{\"val\":0.5}", JsonValue.class);
Expand Down

0 comments on commit f7eeba6

Please sign in to comment.