Interval<Integer> interval1 = Intervals.open(3, 6);
Here 3
is the lower bound, and 6
is the upper bound.
assertEquals(interval1.lowerBound(), 3);
After writing the test, there is a red underline saying:
ambiguous method call.Both assertEquals(object, object) assertEquals(long, long)
The problem is that you're calling assertEquals
with a Long
and an int
, so the compiler can't tell whether you want assertEquals(long, long)
(autounboxing the Long
) or assertEquals(Object, Object)
(autoboxing the int
).
To fix this, you need to handle the unboxing or boxing yourself, by writing either this:
assertEquals(3L, interval1.lowerBound().longValue());
or this:
assertEquals(Long.valueOf(3L), interval1.lowerBound());
(Incidentally, note that I swapped the order of the two arguments for you. assertEquals
expects the first argument to be the expected value and the second to be the actual value. This doesn't affect the assertion itself, but it affects the exception-message that's generated when the assertion fails.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With