From: David ‘Bombe’ Roden Date: Sat, 2 Nov 2013 10:32:14 +0000 (+0100) Subject: Add unit test for IntegerRangePredicate. X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=4b15a53178c89501b5269470e241c0b931ef9b87 Add unit test for IntegerRangePredicate. --- diff --git a/src/test/java/net/pterodactylus/sone/utils/IntegerRangePredicateTest.java b/src/test/java/net/pterodactylus/sone/utils/IntegerRangePredicateTest.java new file mode 100644 index 0000000..26e3756 --- /dev/null +++ b/src/test/java/net/pterodactylus/sone/utils/IntegerRangePredicateTest.java @@ -0,0 +1,47 @@ +package net.pterodactylus.sone.utils; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +import org.junit.Test; + +/** + * Unit test for {@link IntegerRangePredicate}. + * + * @author David Roden + */ +public class IntegerRangePredicateTest { + + private final IntegerRangePredicate integerRangePredicate = new IntegerRangePredicate(-12, 38); + + @Test + public void negativeValueInRange() { + assertThat(integerRangePredicate.apply(-4), is(true)); + } + + @Test + public void positiveValueInRange() { + assertThat(integerRangePredicate.apply(7), is(true)); + } + + @Test + public void negativeBoundaryInRange() { + assertThat(integerRangePredicate.apply(-12), is(true)); + } + + @Test + public void positiveBoundaryInRange() { + assertThat(integerRangePredicate.apply(38), is(true)); + } + + @Test + public void negativeValueOutOfRange() { + assertThat(integerRangePredicate.apply(-24), is(false)); + } + + @Test + public void positiveValueOutOfRange() { + assertThat(integerRangePredicate.apply(40), is(false)); + } + +}