Skip to content

Commit 7231d18

Browse files
committed
test: VariationDiff::computeAllFeatureNames()
1 parent f677560 commit 7231d18

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import static org.junit.jupiter.api.Assertions.assertIterableEquals;
2+
3+
import java.io.IOException;
4+
import java.nio.file.Path;
5+
import java.util.List;
6+
7+
import org.junit.jupiter.params.ParameterizedTest;
8+
import org.junit.jupiter.params.provider.MethodSource;
9+
import org.variantsync.diffdetective.diff.result.DiffParseException;
10+
import org.variantsync.diffdetective.variation.DiffLinesLabel;
11+
import org.variantsync.diffdetective.variation.Label;
12+
import org.variantsync.diffdetective.variation.diff.VariationDiff;
13+
import org.variantsync.diffdetective.variation.diff.parse.VariationDiffParseOptions;
14+
15+
/**
16+
* Test for {@link VariationDiff#computeAllFeatureNames()}.
17+
*/
18+
public class FeatureNamesTest {
19+
private final static Path
20+
testDir = Constants.RESOURCE_DIR.resolve("diffs"),
21+
collapseDir = testDir.resolve("collapse"),
22+
moveDir = testDir.resolve("move");
23+
24+
public record TestCase<L extends Label>(VariationDiff<L> diff, List<String> features) {
25+
public static TestCase<DiffLinesLabel> fromFile(Path p, String... features) throws IOException, DiffParseException {
26+
return new TestCase<>(
27+
VariationDiff.fromFile(p, VariationDiffParseOptions.Default),
28+
List.of(features)
29+
);
30+
}
31+
};
32+
33+
private static List<TestCase<DiffLinesLabel>> diffFeatureNameTestCases() throws IOException, DiffParseException {
34+
return List.of(
35+
TestCase.fromFile(collapseDir.resolve("elif.txt"), "A", "B", "C", "D", "E"),
36+
TestCase.fromFile(collapseDir.resolve("simple.txt"), "A", "B", "C"),
37+
TestCase.fromFile(moveDir.resolve("simple.txt"), "X", "Y")
38+
);
39+
}
40+
41+
@ParameterizedTest
42+
@MethodSource("diffFeatureNameTestCases")
43+
public void testComputeAllFeatureNames(TestCase<DiffLinesLabel> testCase) {
44+
assertIterableEquals(testCase.diff().computeAllFeatureNames(), testCase.features());
45+
}
46+
}

0 commit comments

Comments
 (0)