From 4b15a53178c89501b5269470e241c0b931ef9b87 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 2 Nov 2013 11:32:14 +0100 Subject: [PATCH] Add unit test for IntegerRangePredicate. --- .../sone/utils/IntegerRangePredicateTest.java | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/test/java/net/pterodactylus/sone/utils/IntegerRangePredicateTest.java 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)); + } + +} -- 2.7.4