org.hamcrest.number.IsNaN Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hamcrest Show documentation
Show all versions of hamcrest Show documentation
Core API and libraries of hamcrest matcher framework.
package org.hamcrest.number;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
/**
* Is the value a number actually not a number (NaN)?
*/
public final class IsNaN extends TypeSafeMatcher {
private IsNaN() { }
@Override
public boolean matchesSafely(Double item) {
return Double.isNaN(item);
}
@Override
public void describeMismatchSafely(Double item, Description mismatchDescription) {
mismatchDescription.appendText("was ").appendValue(item);
}
@Override
public void describeTo(Description description) {
description.appendText("a double value of NaN");
}
/**
* Creates a matcher of {@link Double}s that matches when an examined double is not a number.
* For example:
* assertThat(Double.NaN, is(notANumber()))
*/
public static Matcher notANumber() {
return new IsNaN();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy