forked from sqlancer/sqlancer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestComparatorHelper.java
More file actions
54 lines (44 loc) · 2.13 KB
/
TestComparatorHelper.java
File metadata and controls
54 lines (44 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package sqlancer;
import static org.junit.jupiter.api.Assertions.assertThrowsExactly;
import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.api.Test;
public class TestComparatorHelper {
// TODO: Implement tests for the other ComparatorHelper methods
@Test
public void testAssumeResultSetsAreEqualWithEqualSets() {
List<String> r1 = Arrays.asList("a", "b", "c");
List<String> r2 = Arrays.asList("a", "b", "c");
ComparatorHelper.assumeResultSetsAreEqual(r1, r2, "", Arrays.asList(""), null);
}
@Test
public void testAssumeResultSetsAreEqualWithUnequalLengthSets() {
List<String> r1 = Arrays.asList("a", "b", "c");
List<String> r2 = Arrays.asList("a", "b", "c", "d", "g");
// NullPointerException is raised instead of AssertionError because state is null and the state.getState()...
// line occurs before AssertionError is thrown, but it's good enough as an indicator that one of the Exceptions
// is raised
assertThrowsExactly(NullPointerException.class, () -> {
ComparatorHelper.assumeResultSetsAreEqual(r1, r2, "", Arrays.asList(""), null);
});
}
@Test
public void testAssumeResultSetsAreEqualWithUnequalValueSets() {
List<String> r1 = Arrays.asList("a", "b", "c");
List<String> r2 = Arrays.asList("a", "b", "d");
// NullPointerException is raised instead of AssertionError because state is null and the state.getState()...
// line occurs before AssertionError is thrown, but it's good enough as an indicator that one of the Exceptions
// is raised
assertThrowsExactly(NullPointerException.class, () -> {
ComparatorHelper.assumeResultSetsAreEqual(r1, r2, "", Arrays.asList(""), null);
});
}
@Test
public void testAssumeResultSetsAreEqualWithCanonicalizationRule() {
List<String> r1 = Arrays.asList("a", "b", "c");
List<String> r2 = Arrays.asList("a", "b", "d");
ComparatorHelper.assumeResultSetsAreEqual(r1, r2, "", Arrays.asList(""), null, (String s) -> {
return s.equals("d") ? "c" : s;
});
}
}