Skip to content

Commit 8e5ff5e

Browse files
committed
Update OptimizelyJSONWithGsonParserTest to demonstrate Long parsing
1 parent 16d38ef commit 8e5ff5e

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

core-api/src/test/java/com/optimizely/ab/optimizelyjson/OptimizelyJSONWithGsonParserTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,24 @@ public void testGetValueWithNotMatchingType() throws JsonParseException {
5050
@Test
5151
public void testIntegerProcessing() throws JsonParseException {
5252

53-
// GSON parser toMap() adds ".0" to all integers
53+
// GSON parser toMap() converts integers to longs
5454

5555
String json = "{\"k1\":1,\"k2\":2.5,\"k3\":{\"kk1\":3,\"kk2\":4.0}}";
5656

5757
Map<String,Object> m2 = new HashMap<String,Object>();
58-
m2.put("kk1", 3.0);
58+
m2.put("kk1", 3L);
5959
m2.put("kk2", 4.0);
6060

6161
Map<String,Object> m1 = new HashMap<String,Object>();
62-
m1.put("k1", 1.0);
62+
m1.put("k1", 1L);
6363
m1.put("k2", 2.5);
6464
m1.put("k3", m2);
6565

6666
OptimizelyJSON oj1 = new OptimizelyJSON(json, getParser());
67-
assertEquals(oj1.toMap(), m1);
67+
Map<String, Object> ojMap = oj1.toMap();
68+
for (String key : m1.keySet()) {
69+
assertEquals(m1.get(key), ojMap.get(key));
70+
}
6871
}
6972

7073
@Test

0 commit comments

Comments
 (0)