Unit test tweaks
This commit is contained in:
parent
2405219668
commit
95335a8799
|
@ -887,7 +887,7 @@ public abstract class BaseTest {
|
|||
assertTrue("error is not a GrammarSemanticsMessage",
|
||||
foundMsg instanceof GrammarSemanticsMessage);
|
||||
*/
|
||||
assertTrue(Arrays.equals(expectedMessage.getArgs(), foundMsg.getArgs()));
|
||||
assertArrayEquals(expectedMessage.getArgs(), foundMsg.getArgs());
|
||||
}
|
||||
|
||||
public static class FilteringTokenStream extends CommonTokenStream {
|
||||
|
|
|
@ -72,7 +72,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
IntervalSet s2 = IntervalSet.of(13,15);
|
||||
String expecting = "{13..15}";
|
||||
String result = (s.and(s2)).toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testRangeAndIsolatedElement() throws Exception {
|
||||
|
@ -80,7 +80,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
IntervalSet s2 = IntervalSet.of('d');
|
||||
String expecting = "100";
|
||||
String result = (s.and(s2)).toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testEmptyIntersection() throws Exception {
|
||||
|
@ -88,7 +88,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
IntervalSet s2 = IntervalSet.of('0','9');
|
||||
String expecting = "{}";
|
||||
String result = (s.and(s2)).toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testEmptyIntersectionSingleElements() throws Exception {
|
||||
|
@ -96,7 +96,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
IntervalSet s2 = IntervalSet.of('d');
|
||||
String expecting = "{}";
|
||||
String result = (s.and(s2)).toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testNotSingleElement() throws Exception {
|
||||
|
@ -105,7 +105,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
IntervalSet s = IntervalSet.of(50,50);
|
||||
String expecting = "{1..49, 51..1000, 2000..3000}";
|
||||
String result = (s.complement(vocabulary)).toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testNotSet() throws Exception {
|
||||
|
@ -115,7 +115,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
s.add(250,300);
|
||||
String expecting = "{1..4, 6..49, 61..249, 301..1000}";
|
||||
String result = (s.complement(vocabulary)).toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testNotEqualSet() throws Exception {
|
||||
|
@ -123,7 +123,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
IntervalSet s = IntervalSet.of(1,1000);
|
||||
String expecting = "{}";
|
||||
String result = (s.complement(vocabulary)).toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testNotSetEdgeElement() throws Exception {
|
||||
|
@ -131,7 +131,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
IntervalSet s = IntervalSet.of(1);
|
||||
String expecting = "2";
|
||||
String result = (s.complement(vocabulary)).toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testNotSetFragmentedVocabulary() throws Exception {
|
||||
|
@ -144,7 +144,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
s.add(10000); // this is outside range of vocab and should be ignored
|
||||
String expecting = "{1..2, 4..49, 61..249, 1000..2000, 9999}";
|
||||
String result = (s.complement(vocabulary)).toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testSubtractOfCompletelyContainedRange() throws Exception {
|
||||
|
@ -152,7 +152,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
IntervalSet s2 = IntervalSet.of(12,15);
|
||||
String expecting = "{10..11, 16..20}";
|
||||
String result = (s.subtract(s2)).toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testSubtractOfOverlappingRangeFromLeft() throws Exception {
|
||||
|
@ -160,12 +160,12 @@ public class TestIntervalSet extends BaseTest {
|
|||
IntervalSet s2 = IntervalSet.of(5,11);
|
||||
String expecting = "{12..20}";
|
||||
String result = (s.subtract(s2)).toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
|
||||
IntervalSet s3 = IntervalSet.of(5,10);
|
||||
expecting = "{11..20}";
|
||||
result = (s.subtract(s3)).toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testSubtractOfOverlappingRangeFromRight() throws Exception {
|
||||
|
@ -173,12 +173,12 @@ public class TestIntervalSet extends BaseTest {
|
|||
IntervalSet s2 = IntervalSet.of(15,25);
|
||||
String expecting = "{10..14}";
|
||||
String result = (s.subtract(s2)).toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
|
||||
IntervalSet s3 = IntervalSet.of(20,25);
|
||||
expecting = "{10..19}";
|
||||
result = (s.subtract(s3)).toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testSubtractOfCompletelyCoveredRange() throws Exception {
|
||||
|
@ -186,7 +186,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
IntervalSet s2 = IntervalSet.of(1,25);
|
||||
String expecting = "{}";
|
||||
String result = (s.subtract(s2)).toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testSubtractOfRangeSpanningMultipleRanges() throws Exception {
|
||||
|
@ -196,12 +196,12 @@ public class TestIntervalSet extends BaseTest {
|
|||
IntervalSet s2 = IntervalSet.of(5,55); // covers one and touches 2nd range
|
||||
String expecting = "{56..60}";
|
||||
String result = (s.subtract(s2)).toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
|
||||
IntervalSet s3 = IntervalSet.of(15,55); // touches both
|
||||
expecting = "{10..14, 56..60}";
|
||||
result = (s.subtract(s3)).toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
/** The following was broken:
|
||||
|
@ -214,20 +214,16 @@ public class TestIntervalSet extends BaseTest {
|
|||
s2.add(117,200);
|
||||
String expecting = "116";
|
||||
String result = (s.subtract(s2)).toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testSimpleEquals() throws Exception {
|
||||
IntervalSet s = IntervalSet.of(10,20);
|
||||
IntervalSet s2 = IntervalSet.of(10,20);
|
||||
Boolean expecting = new Boolean(true);
|
||||
Boolean result = new Boolean(s.equals(s2));
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(s, s2);
|
||||
|
||||
IntervalSet s3 = IntervalSet.of(15,55);
|
||||
expecting = new Boolean(false);
|
||||
result = new Boolean(s.equals(s3));
|
||||
assertEquals(result, expecting);
|
||||
assertNotEquals(s, s3);
|
||||
}
|
||||
|
||||
@Test public void testEquals() throws Exception {
|
||||
|
@ -237,15 +233,11 @@ public class TestIntervalSet extends BaseTest {
|
|||
IntervalSet s2 = IntervalSet.of(10,20);
|
||||
s2.add(2);
|
||||
s2.add(499,501);
|
||||
Boolean expecting = new Boolean(true);
|
||||
Boolean result = new Boolean(s.equals(s2));
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(s, s2);
|
||||
|
||||
IntervalSet s3 = IntervalSet.of(10,20);
|
||||
s3.add(2);
|
||||
expecting = new Boolean(false);
|
||||
result = new Boolean(s.equals(s3));
|
||||
assertEquals(result, expecting);
|
||||
assertNotEquals(s, s3);
|
||||
}
|
||||
|
||||
@Test public void testSingleElementMinusDisjointSet() throws Exception {
|
||||
|
@ -254,7 +246,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
s2.add(10,20);
|
||||
String expecting = "{}"; // 15 - {1..5, 10..20} = {}
|
||||
String result = s.subtract(s2).toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testMembership() throws Exception {
|
||||
|
@ -277,7 +269,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
s2.add(18);
|
||||
String expecting = "{15, 18}";
|
||||
String result = (s.and(s2)).toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testIntersectionWithTwoContainedElementsReversed() throws Exception {
|
||||
|
@ -287,7 +279,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
s2.add(18);
|
||||
String expecting = "{15, 18}";
|
||||
String result = (s2.and(s)).toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testComplement() throws Exception {
|
||||
|
@ -296,7 +288,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
IntervalSet s2 = IntervalSet.of(100,102);
|
||||
String expecting = "102";
|
||||
String result = (s.complement(s2)).toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testComplement2() throws Exception {
|
||||
|
@ -304,7 +296,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
IntervalSet s2 = IntervalSet.of(100,102);
|
||||
String expecting = "102";
|
||||
String result = (s.complement(s2)).toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testComplement3() throws Exception {
|
||||
|
@ -312,7 +304,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
s.add(99, Lexer.MAX_CHAR_VALUE);
|
||||
String expecting = "{97..98}";
|
||||
String result = (s.complement(1, Lexer.MAX_CHAR_VALUE)).toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testMergeOfRangesAndSingleValues() throws Exception {
|
||||
|
@ -322,7 +314,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
s.add(43,65534);
|
||||
String expecting = "{0..65534}";
|
||||
String result = s.toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testMergeOfRangesAndSingleValuesReverse() throws Exception {
|
||||
|
@ -331,7 +323,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
s.add(0,41);
|
||||
String expecting = "{0..65534}";
|
||||
String result = s.toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testMergeWhereAdditionMergesTwoExistingIntervals() throws Exception {
|
||||
|
@ -343,7 +335,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
s.add(11,41);
|
||||
String expecting = "{0..65534}";
|
||||
String result = s.toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testMergeWithDoubleOverlap() throws Exception {
|
||||
|
@ -352,7 +344,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
s.add(5,25); // overlaps two!
|
||||
String expecting = "{1..30}";
|
||||
String result = s.toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testSize() throws Exception {
|
||||
|
@ -361,7 +353,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
s.add(5,19);
|
||||
String expecting = "32";
|
||||
String result = String.valueOf(s.size());
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testToList() throws Exception {
|
||||
|
@ -370,7 +362,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
s.add(5,5);
|
||||
String expecting = "[5, 20, 21, 22, 23, 24, 25, 50, 51, 52, 53, 54, 55]";
|
||||
String result = String.valueOf(s.toList());
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
/** The following was broken:
|
||||
|
@ -386,7 +378,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
s2.add('s',200);
|
||||
String expecting = "{0..113, 115, 117..200}";
|
||||
String result = (s.and(s2)).toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testRmSingleElement() throws Exception {
|
||||
|
@ -395,7 +387,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
s.remove(-3);
|
||||
String expecting = "{1..10}";
|
||||
String result = s.toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testRmLeftSide() throws Exception {
|
||||
|
@ -404,7 +396,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
s.remove(1);
|
||||
String expecting = "{-3, 2..10}";
|
||||
String result = s.toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testRmRightSide() throws Exception {
|
||||
|
@ -413,7 +405,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
s.remove(10);
|
||||
String expecting = "{-3, 1..9}";
|
||||
String result = s.toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
@Test public void testRmMiddleRange() throws Exception {
|
||||
|
@ -422,7 +414,7 @@ public class TestIntervalSet extends BaseTest {
|
|||
s.remove(5);
|
||||
String expecting = "{-3, 1..4, 6..10}";
|
||||
String result = s.toString();
|
||||
assertEquals(result, expecting);
|
||||
assertEquals(expecting, result);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -94,6 +94,7 @@ import java.util.logging.Logger;
|
|||
import java.util.zip.CRC32;
|
||||
import java.util.zip.Checksum;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class TestPerformance extends BaseTest {
|
||||
|
@ -770,8 +771,7 @@ public class TestPerformance extends BaseTest {
|
|||
}
|
||||
}
|
||||
|
||||
Assert.assertTrue(parseResult instanceof ParseTree);
|
||||
|
||||
assertThat(parseResult, instanceOf(ParseTree.class));
|
||||
if (BUILD_PARSE_TREES && BLANK_LISTENER) {
|
||||
ParseTreeWalker.DEFAULT.walk(listener, (ParseTree)parseResult);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue