Skip to content

Commit 99b9a78

Browse files
committed
Merge pull request skyscreamer#28 from carterpage/dependency_test
Added dependency test (but commented it out) for issue skyscreamer#25
2 parents edeb9a3 + ab1e08d commit 99b9a78

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.skyscreamer.jsonassert;
2+
3+
import org.json.JSONObject;
4+
import org.junit.Assert;
5+
6+
/**
7+
* Unit tests for our external/third-party dependencies.
8+
*
9+
* @author Carter Page <carter@skyscreamer.org>
10+
*/
11+
public class DependencyTest {
12+
//@Test // For https://github.com/skyscreamer/JSONassert/issues/25
13+
public void testJSonGetLong() throws Exception {
14+
Long target = -4611686018427386614L;
15+
String targetString = target.toString();
16+
17+
JSONObject value = new JSONObject().put("id", target);
18+
Assert.assertEquals(target, (Long) value.getLong("id")); //Correct: when put as long getLong is correct
19+
20+
value = new JSONObject().put("id", targetString);
21+
Assert.assertEquals(target, (Long) Long.parseLong(value.getString("id"))); //Correct: when put as String getString is correct
22+
Assert.assertEquals(target, (Long) value.getLong("id")); //Bug: Having json convert the string to long fails
23+
}
24+
}

0 commit comments

Comments
 (0)