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