1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.functor.core.comparator;
18
19 import static org.junit.Assert.assertEquals;
20 import static org.junit.Assert.assertFalse;
21 import static org.junit.Assert.assertTrue;
22
23 import org.apache.commons.functor.core.Constant;
24 import org.junit.Test;
25
26
27
28
29
30 public class TestIsGreaterThan extends BaseComparisonPredicateTest {
31
32
33
34
35 protected Object makeFunctor() {
36 return new IsGreaterThan<Comparable<?>>();
37 }
38
39
40
41
42 @Test
43 public void testTest() throws Exception {
44 IsGreaterThan<Integer> p = new IsGreaterThan<Integer>();
45 assertFalse(p.test(new Integer(2),new Integer(4)));
46 assertFalse(p.test(new Integer(3),new Integer(4)));
47 assertFalse(p.test(new Integer(4),new Integer(4)));
48 assertTrue(p.test(new Integer(5),new Integer(4)));
49 assertTrue(p.test(new Integer(6),new Integer(4)));
50 }
51
52 @Test
53 public void testInstance() {
54 assertTrue(IsGreaterThan.instance(new Integer(7)).test(new Integer(8)));
55 assertTrue(! IsGreaterThan.instance(new Integer(7)).test(new Integer(6)));
56 }
57
58 @Test
59 @SuppressWarnings("unchecked")
60 public void testEquals() throws Exception {
61 IsGreaterThan<Comparable<?>> p = new IsGreaterThan<Comparable<?>>();
62 assertEquals(p,p);
63
64 assertObjectsAreEqual(p,new IsGreaterThan<Comparable<?>>());
65 assertObjectsAreEqual(p,new IsGreaterThan<Comparable<?>>(new ComparableComparator()));
66 assertObjectsAreEqual(p,IsGreaterThan.instance());
67 assertObjectsAreNotEqual(p,Constant.FALSE);
68 }
69
70 }