1 package net.pterodactylus.sone.utils;
3 import static net.pterodactylus.sone.utils.IntegerRangePredicate.range;
4 import static org.hamcrest.MatcherAssert.assertThat;
5 import static org.hamcrest.Matchers.is;
7 import net.pterodactylus.sone.TestUtil;
12 * Unit test for {@link IntegerRangePredicate}.
14 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
16 public class IntegerRangePredicateTest {
18 private final IntegerRangePredicate predicate =
19 new IntegerRangePredicate(-50, 50);
22 public void predicateMatchesNumberWithinBounds() {
23 assertThat(predicate.apply(17), is(true));
27 public void predicateMatchesLowerBoundary() {
28 assertThat(predicate.apply(-50), is(true));
32 public void predicateDoesNotMatchOneBelowLowerBoundary() {
33 assertThat(predicate.apply(-51), is(false));
37 public void predicateMatchesUpperBoundary() {
38 assertThat(predicate.apply(50), is(true));
42 public void predicateDoesNotMatchesOneAboveUpperBoundary() {
43 assertThat(predicate.apply(51), is(false));
47 public void staticCreatorMethodCreatesPredicate() {
48 IntegerRangePredicate predicate = range(-50, 50);
49 assertThat(TestUtil.<Integer>getPrivateField(predicate, "lowerBound"),
51 assertThat(TestUtil.<Integer>getPrivateField(predicate, "upperBound"),