Formating.

This commit is contained in:
ggregory 2016-04-19 17:56:16 -07:00
parent c158713b66
commit e830027629
1 changed files with 46 additions and 47 deletions

View File

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