| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
package org.easymock.tests2; |
| 6 |
|
|
| 7 |
|
import static org.junit.Assert.*; |
| 8 |
|
|
| 9 |
|
import java.math.BigDecimal; |
| 10 |
|
|
| 11 |
|
import org.easymock.internal.matchers.*; |
| 12 |
|
import org.junit.Test; |
| 13 |
|
|
|
|
|
| 81,5% |
Uncovered Elements: 5 (27) |
Complexity: 9 |
Complexity Density: 0,5 |
|
| 14 |
|
public class CompareToTest { |
| 15 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
1
PASS
|
|
| 16 |
1
|
@Test... |
| 17 |
|
public void testNotComparable() { |
| 18 |
1
|
CompareTo<Long> cmpTo = new CompareTo<Long>(5L) { |
| 19 |
|
|
| 20 |
|
private static final long serialVersionUID = 1L; |
| 21 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 22 |
0
|
@Override... |
| 23 |
|
protected String getName() { |
| 24 |
0
|
return null; |
| 25 |
|
} |
| 26 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
| 27 |
0
|
@Override... |
| 28 |
|
protected boolean matchResult(int result) { |
| 29 |
0
|
fail("Shouldn't be called since the passed argument is not Comparable"); |
| 30 |
0
|
return true; |
| 31 |
|
} |
| 32 |
|
|
| 33 |
|
}; |
| 34 |
|
|
| 35 |
1
|
assertFalse(cmpTo.matches(new Object())); |
| 36 |
|
} |
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1
PASS
|
|
| 37 |
1
|
@Test... |
| 38 |
|
public void testLessThan() { |
| 39 |
1
|
test(new LessThan<String>("b"), true, false, false, "lt"); |
| 40 |
|
} |
| 41 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1
PASS
|
|
| 42 |
1
|
@Test... |
| 43 |
|
public void testGreateThan() { |
| 44 |
1
|
test(new GreaterThan<String>("b"), false, true, false, "gt"); |
| 45 |
|
} |
| 46 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1
PASS
|
|
| 47 |
1
|
@Test... |
| 48 |
|
public void testLessOrEqual() { |
| 49 |
1
|
test(new LessOrEqual<String>("b"), true, false, true, "leq"); |
| 50 |
|
} |
| 51 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1
PASS
|
|
| 52 |
1
|
@Test... |
| 53 |
|
public void testGreateOrEqual() { |
| 54 |
1
|
test(new GreaterOrEqual<String>("b"), false, true, true, "geq"); |
| 55 |
|
} |
| 56 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
1
PASS
|
|
| 57 |
1
|
@Test... |
| 58 |
|
public void testCompareEqual() { |
| 59 |
1
|
test(new CompareEqual<String>("b"), false, false, true, "cmpEq"); |
| 60 |
|
|
| 61 |
|
|
| 62 |
|
|
| 63 |
1
|
CompareEqual<BigDecimal> cmpEq = new CompareEqual<BigDecimal>( |
| 64 |
|
new BigDecimal("5.00")); |
| 65 |
1
|
assertTrue(cmpEq.matches(new BigDecimal("5"))); |
| 66 |
|
} |
| 67 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
|
| 68 |
5
|
private void test(CompareTo<String> cmpTo, boolean lower, boolean higher,... |
| 69 |
|
boolean equals, String name) { |
| 70 |
|
|
| 71 |
5
|
assertEquals(lower, cmpTo.matches("a")); |
| 72 |
5
|
assertEquals(equals, cmpTo.matches("b")); |
| 73 |
5
|
assertEquals(higher, cmpTo.matches("c")); |
| 74 |
|
|
| 75 |
5
|
StringBuffer sb = new StringBuffer(); |
| 76 |
5
|
cmpTo.appendTo(sb); |
| 77 |
5
|
assertEquals(name + "(b)", sb.toString()); |
| 78 |
|
} |
| 79 |
|
} |