New failing test to show that JsonPrimitive.equals() is broken for values that are out of 'long' range

This commit is contained in:
Jesse Wilson 2011-09-09 07:58:52 +00:00
parent e756608568
commit 2ee89879e1

View File

@ -226,6 +226,12 @@ public class JsonPrimitiveTest extends TestCase {
MoreAsserts.assertEqualsAndHashCode(new JsonPrimitive(Float.NaN), new JsonPrimitive(Double.NaN));
}
public void testEqualsIntegerAndBigInteger() {
JsonPrimitive a = new JsonPrimitive(5L);
JsonPrimitive b = new JsonPrimitive(new BigInteger("18446744073709551621")); // 2^64 + 5
assertFalse(a + " equals " + b, a.equals(b));
}
public void testEqualsDoesNotEquateStringAndNonStringTypes() {
assertFalse(new JsonPrimitive("true").equals(new JsonPrimitive(true)));
assertFalse(new JsonPrimitive("0").equals(new JsonPrimitive(0)));