Formating.
This commit is contained in:
parent
c158713b66
commit
e830027629
|
@ -49,27 +49,26 @@ public class RangeTest {
|
||||||
@SuppressWarnings("cast") // intRange
|
@SuppressWarnings("cast") // intRange
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
byteRange = Range.between((byte) 0, (byte) 5);
|
byteRange = Range.between((byte) 0, (byte) 5);
|
||||||
byteRange2 = Range.between((byte) 0, (byte) 5);
|
byteRange2 = Range.between((byte) 0, (byte) 5);
|
||||||
byteRange3 = Range.between((byte) 0, (byte) 10);
|
byteRange3 = Range.between((byte) 0, (byte) 10);
|
||||||
|
|
||||||
intRange = Range.between((int) 10, (int) 20);
|
intRange = Range.between((int) 10, (int) 20);
|
||||||
longRange = Range.between((long) 10, (long) 20);
|
longRange = Range.between((long) 10, (long) 20);
|
||||||
floatRange = Range.between((float) 10, (float) 20);
|
floatRange = Range.between((float) 10, (float) 20);
|
||||||
doubleRange = Range.between((double) 10, (double) 20);
|
doubleRange = Range.between((double) 10, (double) 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
@Test
|
@Test
|
||||||
public void testComparableConstructors() {
|
public void testComparableConstructors() {
|
||||||
final Comparable c =
|
final Comparable c = new Comparable() {
|
||||||
new Comparable() {
|
@Override
|
||||||
@Override
|
public int compareTo(final Object other) {
|
||||||
public int compareTo(final Object other) {
|
return 1;
|
||||||
return 1;
|
}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
final Range r1 = Range.is(c);
|
final Range r1 = Range.is(c);
|
||||||
final Range r2 = Range.between(c, c);
|
final Range r2 = Range.between(c, c);
|
||||||
assertEquals(true, r1.isNaturalOrdering());
|
assertEquals(true, r1.isNaturalOrdering());
|
||||||
|
@ -77,21 +76,21 @@ public class RangeTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsWithCompare(){
|
public void testIsWithCompare() {
|
||||||
final Comparator<Integer> c = new Comparator<Integer>(){
|
final Comparator<Integer> c = new Comparator<Integer>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(final Integer o1, final Integer o2) {
|
public int compare(final Integer o1, final Integer o2) {
|
||||||
return 0; // all integers are equal
|
return 0; // all integers are equal
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Range<Integer> ri = Range.is(10);
|
Range<Integer> ri = Range.is(10);
|
||||||
assertFalse("should not contain null",ri.contains(null));
|
assertFalse("should not contain null", ri.contains(null));
|
||||||
assertTrue("should contain 10",ri.contains(10));
|
assertTrue("should contain 10", ri.contains(10));
|
||||||
assertFalse("should not contain 11",ri.contains(11));
|
assertFalse("should not contain 11", ri.contains(11));
|
||||||
ri = Range.is(10,c);
|
ri = Range.is(10, c);
|
||||||
assertFalse("should not contain null",ri.contains(null));
|
assertFalse("should not contain null", ri.contains(null));
|
||||||
assertTrue("should contain 10",ri.contains(10));
|
assertTrue("should contain 10", ri.contains(10));
|
||||||
assertTrue("should contain 11",ri.contains(11));
|
assertTrue("should contain 11", ri.contains(11));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -134,7 +133,7 @@ public class RangeTest {
|
||||||
assertFalse("should not contain ''", rbstr.contains(""));
|
assertFalse("should not contain ''", rbstr.contains(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
@Test
|
@Test
|
||||||
public void testRangeOfChars() {
|
public void testRangeOfChars() {
|
||||||
final Range<Character> chars = Range.between('a', 'z');
|
final Range<Character> chars = Range.between('a', 'z');
|
||||||
|
@ -142,7 +141,7 @@ public class RangeTest {
|
||||||
assertFalse(chars.contains('B'));
|
assertFalse(chars.contains('B'));
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
@Test
|
@Test
|
||||||
public void testEqualsObject() {
|
public void testEqualsObject() {
|
||||||
assertEquals(byteRange, byteRange);
|
assertEquals(byteRange, byteRange);
|
||||||
|
@ -160,7 +159,7 @@ public class RangeTest {
|
||||||
public void testHashCode() {
|
public void testHashCode() {
|
||||||
assertEquals(byteRange.hashCode(), byteRange2.hashCode());
|
assertEquals(byteRange.hashCode(), byteRange2.hashCode());
|
||||||
assertFalse(byteRange.hashCode() == byteRange3.hashCode());
|
assertFalse(byteRange.hashCode() == byteRange3.hashCode());
|
||||||
|
|
||||||
assertEquals(intRange.hashCode(), intRange.hashCode());
|
assertEquals(intRange.hashCode(), intRange.hashCode());
|
||||||
assertTrue(intRange.hashCode() != 0);
|
assertTrue(intRange.hashCode() != 0);
|
||||||
}
|
}
|
||||||
|
@ -168,7 +167,7 @@ public class RangeTest {
|
||||||
@Test
|
@Test
|
||||||
public void testToString() {
|
public void testToString() {
|
||||||
assertNotNull(byteRange.toString());
|
assertNotNull(byteRange.toString());
|
||||||
|
|
||||||
final String str = intRange.toString();
|
final String str = intRange.toString();
|
||||||
assertEquals("[10..20]", str);
|
assertEquals("[10..20]", str);
|
||||||
assertEquals("[-20..-10]", Range.between(-20, -10).toString());
|
assertEquals("[-20..-10]", Range.between(-20, -10).toString());
|
||||||
|
@ -180,7 +179,7 @@ public class RangeTest {
|
||||||
assertEquals("From 10 to 20", str);
|
assertEquals("From 10 to 20", str);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
@Test
|
@Test
|
||||||
public void testGetMinimum() {
|
public void testGetMinimum() {
|
||||||
assertEquals(10, (int) intRange.getMinimum());
|
assertEquals(10, (int) intRange.getMinimum());
|
||||||
|
@ -200,7 +199,7 @@ public class RangeTest {
|
||||||
@Test
|
@Test
|
||||||
public void testContains() {
|
public void testContains() {
|
||||||
assertFalse(intRange.contains(null));
|
assertFalse(intRange.contains(null));
|
||||||
|
|
||||||
assertFalse(intRange.contains(5));
|
assertFalse(intRange.contains(5));
|
||||||
assertTrue(intRange.contains(10));
|
assertTrue(intRange.contains(10));
|
||||||
assertTrue(intRange.contains(15));
|
assertTrue(intRange.contains(15));
|
||||||
|
@ -211,7 +210,7 @@ public class RangeTest {
|
||||||
@Test
|
@Test
|
||||||
public void testIsAfter() {
|
public void testIsAfter() {
|
||||||
assertFalse(intRange.isAfter(null));
|
assertFalse(intRange.isAfter(null));
|
||||||
|
|
||||||
assertTrue(intRange.isAfter(5));
|
assertTrue(intRange.isAfter(5));
|
||||||
assertFalse(intRange.isAfter(10));
|
assertFalse(intRange.isAfter(10));
|
||||||
assertFalse(intRange.isAfter(15));
|
assertFalse(intRange.isAfter(15));
|
||||||
|
@ -222,7 +221,7 @@ public class RangeTest {
|
||||||
@Test
|
@Test
|
||||||
public void testIsStartedBy() {
|
public void testIsStartedBy() {
|
||||||
assertFalse(intRange.isStartedBy(null));
|
assertFalse(intRange.isStartedBy(null));
|
||||||
|
|
||||||
assertFalse(intRange.isStartedBy(5));
|
assertFalse(intRange.isStartedBy(5));
|
||||||
assertTrue(intRange.isStartedBy(10));
|
assertTrue(intRange.isStartedBy(10));
|
||||||
assertFalse(intRange.isStartedBy(15));
|
assertFalse(intRange.isStartedBy(15));
|
||||||
|
@ -233,7 +232,7 @@ public class RangeTest {
|
||||||
@Test
|
@Test
|
||||||
public void testIsEndedBy() {
|
public void testIsEndedBy() {
|
||||||
assertFalse(intRange.isEndedBy(null));
|
assertFalse(intRange.isEndedBy(null));
|
||||||
|
|
||||||
assertFalse(intRange.isEndedBy(5));
|
assertFalse(intRange.isEndedBy(5));
|
||||||
assertFalse(intRange.isEndedBy(10));
|
assertFalse(intRange.isEndedBy(10));
|
||||||
assertFalse(intRange.isEndedBy(15));
|
assertFalse(intRange.isEndedBy(15));
|
||||||
|
@ -244,7 +243,7 @@ public class RangeTest {
|
||||||
@Test
|
@Test
|
||||||
public void testIsBefore() {
|
public void testIsBefore() {
|
||||||
assertFalse(intRange.isBefore(null));
|
assertFalse(intRange.isBefore(null));
|
||||||
|
|
||||||
assertFalse(intRange.isBefore(5));
|
assertFalse(intRange.isBefore(5));
|
||||||
assertFalse(intRange.isBefore(10));
|
assertFalse(intRange.isBefore(10));
|
||||||
assertFalse(intRange.isBefore(15));
|
assertFalse(intRange.isBefore(15));
|
||||||
|
@ -257,10 +256,10 @@ public class RangeTest {
|
||||||
try {
|
try {
|
||||||
intRange.elementCompareTo(null);
|
intRange.elementCompareTo(null);
|
||||||
fail("NullPointerException should have been thrown");
|
fail("NullPointerException should have been thrown");
|
||||||
} catch(final NullPointerException npe) {
|
} catch (final NullPointerException npe) {
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(-1, intRange.elementCompareTo(5));
|
assertEquals(-1, intRange.elementCompareTo(5));
|
||||||
assertEquals(0, intRange.elementCompareTo(10));
|
assertEquals(0, intRange.elementCompareTo(10));
|
||||||
assertEquals(0, intRange.elementCompareTo(15));
|
assertEquals(0, intRange.elementCompareTo(15));
|
||||||
|
@ -268,7 +267,7 @@ public class RangeTest {
|
||||||
assertEquals(1, intRange.elementCompareTo(25));
|
assertEquals(1, intRange.elementCompareTo(25));
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
@Test
|
@Test
|
||||||
public void testContainsRange() {
|
public void testContainsRange() {
|
||||||
|
|
||||||
|
@ -296,7 +295,7 @@ public class RangeTest {
|
||||||
// touches upper boundary
|
// touches upper boundary
|
||||||
assertTrue(intRange.containsRange(Range.between(11, 20)));
|
assertTrue(intRange.containsRange(Range.between(11, 20)));
|
||||||
assertFalse(intRange.containsRange(Range.between(9, 20)));
|
assertFalse(intRange.containsRange(Range.between(9, 20)));
|
||||||
|
|
||||||
// negative
|
// negative
|
||||||
assertFalse(intRange.containsRange(Range.between(-11, -18)));
|
assertFalse(intRange.containsRange(Range.between(-11, -18)));
|
||||||
}
|
}
|
||||||
|
@ -304,16 +303,16 @@ public class RangeTest {
|
||||||
@Test
|
@Test
|
||||||
public void testIsAfterRange() {
|
public void testIsAfterRange() {
|
||||||
assertFalse(intRange.isAfterRange(null));
|
assertFalse(intRange.isAfterRange(null));
|
||||||
|
|
||||||
assertTrue(intRange.isAfterRange(Range.between(5, 9)));
|
assertTrue(intRange.isAfterRange(Range.between(5, 9)));
|
||||||
|
|
||||||
assertFalse(intRange.isAfterRange(Range.between(5, 10)));
|
assertFalse(intRange.isAfterRange(Range.between(5, 10)));
|
||||||
assertFalse(intRange.isAfterRange(Range.between(5, 20)));
|
assertFalse(intRange.isAfterRange(Range.between(5, 20)));
|
||||||
assertFalse(intRange.isAfterRange(Range.between(5, 25)));
|
assertFalse(intRange.isAfterRange(Range.between(5, 25)));
|
||||||
assertFalse(intRange.isAfterRange(Range.between(15, 25)));
|
assertFalse(intRange.isAfterRange(Range.between(15, 25)));
|
||||||
|
|
||||||
assertFalse(intRange.isAfterRange(Range.between(21, 25)));
|
assertFalse(intRange.isAfterRange(Range.between(21, 25)));
|
||||||
|
|
||||||
assertFalse(intRange.isAfterRange(Range.between(10, 20)));
|
assertFalse(intRange.isAfterRange(Range.between(10, 20)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,7 +343,7 @@ public class RangeTest {
|
||||||
// touches upper boundary
|
// touches upper boundary
|
||||||
assertTrue(intRange.isOverlappedBy(Range.between(11, 20)));
|
assertTrue(intRange.isOverlappedBy(Range.between(11, 20)));
|
||||||
assertTrue(intRange.isOverlappedBy(Range.between(9, 20)));
|
assertTrue(intRange.isOverlappedBy(Range.between(9, 20)));
|
||||||
|
|
||||||
// negative
|
// negative
|
||||||
assertFalse(intRange.isOverlappedBy(Range.between(-11, -18)));
|
assertFalse(intRange.isOverlappedBy(Range.between(-11, -18)));
|
||||||
}
|
}
|
||||||
|
@ -352,16 +351,16 @@ public class RangeTest {
|
||||||
@Test
|
@Test
|
||||||
public void testIsBeforeRange() {
|
public void testIsBeforeRange() {
|
||||||
assertFalse(intRange.isBeforeRange(null));
|
assertFalse(intRange.isBeforeRange(null));
|
||||||
|
|
||||||
assertFalse(intRange.isBeforeRange(Range.between(5, 9)));
|
assertFalse(intRange.isBeforeRange(Range.between(5, 9)));
|
||||||
|
|
||||||
assertFalse(intRange.isBeforeRange(Range.between(5, 10)));
|
assertFalse(intRange.isBeforeRange(Range.between(5, 10)));
|
||||||
assertFalse(intRange.isBeforeRange(Range.between(5, 20)));
|
assertFalse(intRange.isBeforeRange(Range.between(5, 20)));
|
||||||
assertFalse(intRange.isBeforeRange(Range.between(5, 25)));
|
assertFalse(intRange.isBeforeRange(Range.between(5, 25)));
|
||||||
assertFalse(intRange.isBeforeRange(Range.between(15, 25)));
|
assertFalse(intRange.isBeforeRange(Range.between(15, 25)));
|
||||||
|
|
||||||
assertTrue(intRange.isBeforeRange(Range.between(21, 25)));
|
assertTrue(intRange.isBeforeRange(Range.between(21, 25)));
|
||||||
|
|
||||||
assertFalse(intRange.isBeforeRange(Range.between(10, 20)));
|
assertFalse(intRange.isBeforeRange(Range.between(10, 20)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,7 +385,7 @@ public class RangeTest {
|
||||||
intRange.intersectionWith(Range.between(0, 9));
|
intRange.intersectionWith(Range.between(0, 9));
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
@Test
|
@Test
|
||||||
public void testSerializing() {
|
public void testSerializing() {
|
||||||
SerializationUtils.clone(intRange);
|
SerializationUtils.clone(intRange);
|
||||||
|
|
Loading…
Reference in New Issue