Merge branch 'next' into feature/album-and-image-links
[Sone.git] / src / test / java / net / pterodactylus / sone / utils / IntegerRangePredicateTest.java
1 package net.pterodactylus.sone.utils;
2
3 import static net.pterodactylus.sone.utils.IntegerRangePredicate.range;
4 import static org.hamcrest.MatcherAssert.assertThat;
5 import static org.hamcrest.Matchers.is;
6
7 import net.pterodactylus.sone.TestUtil;
8
9 import org.junit.Test;
10
11 /**
12  * Unit test for {@link IntegerRangePredicate}.
13  *
14  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
15  */
16 public class IntegerRangePredicateTest {
17
18         private final IntegerRangePredicate predicate =
19                         new IntegerRangePredicate(-50, 50);
20
21         @Test
22         public void predicateMatchesNumberWithinBounds() {
23                 assertThat(predicate.apply(17), is(true));
24         }
25
26         @Test
27         public void predicateMatchesLowerBoundary() {
28                 assertThat(predicate.apply(-50), is(true));
29         }
30
31         @Test
32         public void predicateDoesNotMatchOneBelowLowerBoundary() {
33                 assertThat(predicate.apply(-51), is(false));
34         }
35
36         @Test
37         public void predicateMatchesUpperBoundary() {
38                 assertThat(predicate.apply(50), is(true));
39         }
40
41         @Test
42         public void predicateDoesNotMatchesOneAboveUpperBoundary() {
43                 assertThat(predicate.apply(51), is(false));
44         }
45
46         @Test
47         public void staticCreatorMethodCreatesPredicate() {
48                 IntegerRangePredicate predicate = range(-50, 50);
49                 assertThat(TestUtil.<Integer>getPrivateField(predicate, "lowerBound"),
50                                 is(-50));
51                 assertThat(TestUtil.<Integer>getPrivateField(predicate, "upperBound"),
52                                 is(50));
53         }
54
55 }