File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
src/test/java/org/skyscreamer/jsonassert Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments