|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CompareTo | Line # 11 | 5 | 4 | 100% |
1.0
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (17) | |||
| Result | |||
|
0.8
|
org.easymock.tests2.UsageConstraintsTest.greaterOrEqual
org.easymock.tests2.UsageConstraintsTest.greaterOrEqual
|
1 PASS | |
|
0.8
|
org.easymock.tests2.UsageConstraintsTest.greaterThan
org.easymock.tests2.UsageConstraintsTest.greaterThan
|
1 PASS | |
|
0.8
|
org.easymock.tests2.UsageConstraintsTest.lessOrEqual
org.easymock.tests2.UsageConstraintsTest.lessOrEqual
|
1 PASS | |
|
0.8
|
org.easymock.tests2.UsageConstraintsTest.lessThan
org.easymock.tests2.UsageConstraintsTest.lessThan
|
1 PASS | |
|
0.8
|
org.easymock.tests2.CompareToTest.testGreateThan
org.easymock.tests2.CompareToTest.testGreateThan
|
1 PASS | |
|
0.8
|
org.easymock.tests2.CompareToTest.testLessThan
org.easymock.tests2.CompareToTest.testLessThan
|
1 PASS | |
|
0.8
|
org.easymock.tests2.CompareToTest.testGreateOrEqual
org.easymock.tests2.CompareToTest.testGreateOrEqual
|
1 PASS | |
|
0.8
|
org.easymock.tests2.CompareToTest.testCompareEqual
org.easymock.tests2.CompareToTest.testCompareEqual
|
1 PASS | |
|
0.8
|
org.easymock.tests2.CompareToTest.testLessOrEqual
org.easymock.tests2.CompareToTest.testLessOrEqual
|
1 PASS | |
|
0.8
|
org.easymock.tests2.UsageConstraintsTest.constraints
org.easymock.tests2.UsageConstraintsTest.constraints
|
1 PASS | |
|
0.6
|
org.easymock.tests2.CompareToTest.testNotComparable
org.easymock.tests2.CompareToTest.testNotComparable
|
1 PASS | |
|
0.6
|
org.easymock.tests2.UsageConstraintsTest.lessThanOverloaded
org.easymock.tests2.UsageConstraintsTest.lessThanOverloaded
|
1 PASS | |
|
0.6
|
org.easymock.tests2.UsageConstraintsTest.greaterThanOverloaded
org.easymock.tests2.UsageConstraintsTest.greaterThanOverloaded
|
1 PASS | |
|
0.6
|
org.easymock.tests2.UsageConstraintsTest.greaterOrEqualOverloaded
org.easymock.tests2.UsageConstraintsTest.greaterOrEqualOverloaded
|
1 PASS | |
|
0.6
|
org.easymock.tests2.UsageConstraintsTest.lessOrEqualOverloaded
org.easymock.tests2.UsageConstraintsTest.lessOrEqualOverloaded
|
1 PASS | |
|
0.6
|
org.easymock.tests2.UsageConstraintsTest.cmpTo
org.easymock.tests2.UsageConstraintsTest.cmpTo
|
1 PASS | |
|
0.2
|
org.easymock.tests2.UsageMatchersTest.additionalMatchersFailAtReplay
org.easymock.tests2.UsageMatchersTest.additionalMatchersFailAtReplay
|
1 PASS | |
| 1 | /* | |
| 2 | * Copyright (c) 2001-2008 OFFIS, Tammo Freese. | |
| 3 | * This program is made available under the terms of the MIT License. | |
| 4 | */ | |
| 5 | package org.easymock.internal.matchers; | |
| 6 | ||
| 7 | import java.io.Serializable; | |
| 8 | ||
| 9 | import org.easymock.IArgumentMatcher; | |
| 10 | ||
| 11 | public abstract class CompareTo<T extends Comparable<T>> implements IArgumentMatcher, Serializable { | |
| 12 | ||
| 13 | private static final long serialVersionUID = -8447010713532143168L; | |
| 14 | ||
| 15 | private final Comparable<T> expected; | |
| 16 | ||
| 17 | 47 |
public CompareTo(Comparable<T> value) { |
| 18 | 47 | this.expected = value; |
| 19 | } | |
| 20 | ||
| 21 | 96 |
@SuppressWarnings("unchecked") |
| 22 | public boolean matches(Object actual) { | |
| 23 | ||
| 24 | 96 | if(!(actual instanceof Comparable)) { |
| 25 | 1 | return false; |
| 26 | } | |
| 27 | ||
| 28 | 95 | return matchResult(((Comparable) actual).compareTo(expected)); |
| 29 | } | |
| 30 | ||
| 31 | 19 |
public void appendTo(StringBuffer buffer) { |
| 32 | 19 | buffer.append(getName() + "(" + expected + ")"); |
| 33 | } | |
| 34 | ||
| 35 | protected abstract String getName(); | |
| 36 | ||
| 37 | protected abstract boolean matchResult(int result); | |
| 38 | } | |
|
||||||||||