All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hamcrest.number.IsNaN Maven / Gradle / Ivy

There is a newer version: 3.0
Show newest version
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