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
AbstractOptionalDoubleAssert.hasValue(double)
fails with NaN
#3401
Comments
In the meantime, that can be bypassed by testing the double value directly: @Test
void testNaN() {
assertThat(OptionalDouble.of(Double.NaN).getAsDouble()).isNaN();
} |
Thanks for reporting it, @Caceresenzo! |
@scordio Do you need someone to make a change for this? |
Sure, go for it, @pbacz! |
@scordio From the javadoc stating that I propose to replace As this is potentially a breaking change for an edge case I'd like you to confirm if I should proceed with that. |
A solution could be to add This would prevent breaking changes. EDIT: typos |
@Caceresenzo @scordio |
I think having both Currently this passes: assertThat(OptionalDouble.of(Double.NaN))
.isNotEqualTo(Double.NaN); (but I am sure its because its testing against the OptionalDouble and not the optional's value itself) |
I tend to favor this solution, consistent with what the Javadoc already states and also in line with It's indeed a breaking change and the workaround to get the previous behavior would be something like: assertThat(OptionalDouble.of(Double.NaN).getAsDouble()).isSameAs(Double.NaN); @joel-costigliola do you agree? |
@scordio @joel-costigliola |
Integrated thanks @pbacz ! |
Describe the bug
The
AbstractOptionalDoubleAssert.hasValue(double)
javadoc state that NaN values are supported (last line of):assertj/assertj-core/src/main/java/org/assertj/core/api/AbstractOptionalDoubleAssert.java
Lines 120 to 123 in 35e54e0
The nature of NaN values prevents the
==
operator to works, but there is nohasNaNValue()
method or equivalent, and the javadoc clearly state that it should works.Test case reproducing the bug
Result:
The text was updated successfully, but these errors were encountered: