forked from skyscreamer/JSONassert
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDependencyTest.java
More file actions
30 lines (25 loc) · 1.06 KB
/
DependencyTest.java
File metadata and controls
30 lines (25 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package org.skyscreamer.jsonassert;
import org.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
/**
* Unit tests for our external/third-party dependencies.
*
* @author Carter Page <carter@skyscreamer.org>
*/
public class DependencyTest {
@Test
public void nop() {
// Cloudbees doesn't like a unit test class with no tests
}
//@Test // For https://github.com/skyscreamer/JSONassert/issues/25
public void testJSonGetLong() throws Exception {
Long target = -4611686018427386614L;
String targetString = target.toString();
JSONObject value = new JSONObject().put("id", target);
Assert.assertEquals(target, (Long) value.getLong("id")); //Correct: when put as long getLong is correct
value = new JSONObject().put("id", targetString);
Assert.assertEquals(target, (Long) Long.parseLong(value.getString("id"))); //Correct: when put as String getString is correct
Assert.assertEquals(target, (Long) value.getLong("id")); //Bug: Having json convert the string to long fails
}
}