Add unit test for IntegerRangePredicate.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 2 Nov 2013 10:32:14 +0000 (11:32 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Feb 2014 21:25:54 +0000 (22:25 +0100)
src/test/java/net/pterodactylus/sone/utils/IntegerRangePredicateTest.java [new file with mode: 0644]

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 (file)
index 0000000..26e3756
--- /dev/null
@@ -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 <a href="mailto:d.roden@xplosion.de">David Roden</a>
+ */
+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));
+       }
+
+}