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

it.ozimov.cirneco.hamcrest.number.IsPositive Maven / Gradle / Ivy

package it.ozimov.cirneco.hamcrest.number;

import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;


/**
 * Is the value a {@linkplain Number} with negative  value?
 *
 * @since version 0.2 for JDK7
 */
public class IsPositive extends TypeSafeMatcher {

    /**
     * Creates a matcher for {@code N} that matches when the it has a value that is greater than zero.
     * 

* For example: *

assertThat(100, positive())
* will return true. */ public static Matcher positive() { return new IsPositive<>(); } @Override protected boolean matchesSafely(final N number) { return number.doubleValue() > 0D; } @Override protected void describeMismatchSafely(final N item, final Description mismatchDescription) { mismatchDescription.appendValue(item) .appendText(" is not positive"); } @Override public void describeTo(final Description description) { description.appendText("a positive value"); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy