-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the equals
method of JsonPrimitive
to work with BigInteger
#2311
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -300,10 +300,8 @@ public void testEqualsAcrossTypes() { | |
@Test | ||
public void testEqualsIntegerAndBigInteger() { | ||
JsonPrimitive a = new JsonPrimitive(5L); | ||
JsonPrimitive b = new JsonPrimitive(new BigInteger("18446744073709551621")); // 2^64 + 5 | ||
// Ideally, the following assertion should have failed but the price is too much to pay | ||
// assertFalse(a + " equals " + b, a.equals(b)); | ||
assertWithMessage("%s equals %s", a, b).that(a.equals(b)).isTrue(); | ||
JsonPrimitive b = new JsonPrimitive(new BigInteger("18446744073709551621")); | ||
assertWithMessage("%s not equals %s", a, b).that(a.equals(b)).isFalse(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may become irrelevant if we start using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could leave it until we implement |
||
} | ||
|
||
@Test | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW I vigorously disagree with this assessment. Saying values are equal when they aren't is pretty bad, and the fix is neither difficult nor expensive.