Add tests with a better comparator from #132. Fix formating.

This commit is contained in:
ggregory 2016-04-19 17:55:42 -07:00
parent 3f796bf746
commit c158713b66
1 changed files with 25 additions and 25 deletions

View File

@ -95,43 +95,43 @@ public class RangeTest {
}
@Test
public void testBetweenWithCompare(){
final Comparator<Integer> c = new Comparator<Integer>(){
public void testBetweenWithCompare() {
final Comparator<Integer> c = new Comparator<Integer>() {
@Override
public int compare(final Integer o1, final Integer o2) {
return 0; // all integers are equal
}
};
final Comparator<String> lengthComp = new Comparator<String>(){
final Comparator<String> lengthComp = new Comparator<String>() {
@Override
public int compare(final String str1, final String str2) {
return str1.length() - str2.length();
}
};
Range<Integer> rb = Range.between(-10,20);
assertFalse("should not contain null",rb.contains(null));
assertTrue("should contain 10",rb.contains(10));
assertTrue("should contain -10",rb.contains(-10));
assertFalse("should not contain 21",rb.contains(21));
assertFalse("should not contain -11",rb.contains(-11));
rb = Range.between(-10,20,c);
assertFalse("should not contain null",rb.contains(null));
assertTrue("should contain 10",rb.contains(10));
assertTrue("should contain -10",rb.contains(-10));
assertTrue("should contain 21",rb.contains(21));
assertTrue("should contain -11",rb.contains(-11));
Range<Integer> rb = Range.between(-10, 20);
assertFalse("should not contain null", rb.contains(null));
assertTrue("should contain 10", rb.contains(10));
assertTrue("should contain -10", rb.contains(-10));
assertFalse("should not contain 21", rb.contains(21));
assertFalse("should not contain -11", rb.contains(-11));
rb = Range.between(-10, 20, c);
assertFalse("should not contain null", rb.contains(null));
assertTrue("should contain 10", rb.contains(10));
assertTrue("should contain -10", rb.contains(-10));
assertTrue("should contain 21", rb.contains(21));
assertTrue("should contain -11", rb.contains(-11));
Range<String> rbstr = Range.between("house", "i");
assertFalse("should not contain null",rbstr.contains(null));
assertTrue("should contain house",rbstr.contains("house"));
assertTrue("should contain i",rbstr.contains("i"));
assertFalse("should not contain hose",rbstr.contains("hose"));
assertFalse("should not contain ice",rbstr.contains("ice"));
assertFalse("should not contain null", rbstr.contains(null));
assertTrue("should contain house", rbstr.contains("house"));
assertTrue("should contain i", rbstr.contains("i"));
assertFalse("should not contain hose", rbstr.contains("hose"));
assertFalse("should not contain ice", rbstr.contains("ice"));
rbstr = Range.between("house", "i", lengthComp);
assertFalse("should not contain null",rbstr.contains(null));
assertTrue("should contain house",rbstr.contains("house"));
assertTrue("should contain i",rbstr.contains("i"));
assertFalse("should not contain houses",rbstr.contains("houses"));
assertFalse("should not contain ''",rbstr.contains(""));
assertFalse("should not contain null", rbstr.contains(null));
assertTrue("should contain house", rbstr.contains("house"));
assertTrue("should contain i", rbstr.contains("i"));
assertFalse("should not contain houses", rbstr.contains("houses"));
assertFalse("should not contain ''", rbstr.contains(""));
}
//-----------------------------------------------------------------------