aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/moe/nea
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-03-05 20:46:47 +0100
committerLinnea Gräf <nea@nea.moe>2024-03-05 20:46:47 +0100
commit4f704c99ab3f4a294aba9d1f2b0ae7929e2b4a4b (patch)
treea9fa3f57a7efeea0a937aac7fc90fb4df23e5a7b /src/test/java/moe/nea
parentb8c7e6c934ae9e0059ac1ac1455d77319dbc20c0 (diff)
downloadzwirn-4f704c99ab3f4a294aba9d1f2b0ae7929e2b4a4b.tar.gz
zwirn-4f704c99ab3f4a294aba9d1f2b0ae7929e2b4a4b.tar.bz2
zwirn-4f704c99ab3f4a294aba9d1f2b0ae7929e2b4a4b.zip
Add diffing
Diffstat (limited to 'src/test/java/moe/nea')
-rw-r--r--src/test/java/moe/nea/zwirn/ZwirnTest.java59
1 files changed, 49 insertions, 10 deletions
diff --git a/src/test/java/moe/nea/zwirn/ZwirnTest.java b/src/test/java/moe/nea/zwirn/ZwirnTest.java
index 2f80964..b3ed4f5 100644
--- a/src/test/java/moe/nea/zwirn/ZwirnTest.java
+++ b/src/test/java/moe/nea/zwirn/ZwirnTest.java
@@ -11,8 +11,18 @@ import java.util.HashMap;
class ZwirnTest {
@Test
- void mergeTinyFile() throws IOException {
- var base = new TinyFile(
+ void diffTinyFile() throws Exception {
+ var base = getBaseFile();
+ var overlay = getOverlayFile();
+ var merged = Zwirn.mergeTinyFile(base, overlay, "official");
+ var unmerged = Zwirn.createOverlayTinyFile(base, merged, Arrays.asList("official", "named"), "official");
+ TinyV2Writer.write(overlay, Path.of("overlay.tiny"));
+ TinyV2Writer.write(unmerged, Path.of("unmerged.tiny"));
+ }
+
+
+ TinyFile getBaseFile() {
+ return new TinyFile(
new TinyHeader(
Arrays.asList("official", "intermediary", "named"),
2, 0, new HashMap<>()
@@ -20,32 +30,61 @@ class ZwirnTest {
Arrays.asList(
new TinyClass(
Arrays.asList("A", "ClassA", "SomeClass"),
- Arrays.asList(),
+ Arrays.asList(
+ new TinyMethod(
+ "a",
+ Arrays.asList("a", "method_a", "doSomething"),
+ Arrays.asList(
+ new TinyMethodParameter(
+ 0,
+ Arrays.asList("a", "param_a_a", "somethingToOperateOn"),
+ Arrays.asList()
+ )
+ ),
+ Arrays.asList(),
+ Arrays.asList("method comment")
+ )
+ ),
Arrays.asList(new TinyField("a",
Arrays.asList("a", "field_a", "myField"), Arrays.asList("Field comment"))),
Arrays.asList("some comment")
+ ),
+ new TinyClass(
+ Arrays.asList("C", "ClassC", "SomeOtherClass"),
+ Arrays.asList(),
+ Arrays.asList(),
+ Arrays.asList()
)
)
);
- var overlay = new TinyFile(
+ }
+
+ @Test
+ void mergeTinyFile() throws IOException {
+ var base = getBaseFile();
+ var overlay = getOverlayFile();
+ var merged = Zwirn.mergeTinyFile(base, overlay, "official");
+ TinyV2Writer.write(merged, Path.of("out.tiny"));
+ }
+
+ TinyFile getOverlayFile() {
+ return new TinyFile(
new TinyHeader(
- Arrays.asList("official", "intermediary", "named"),
+ Arrays.asList("official", "named"),
2, 0, new HashMap<>()
),
Arrays.asList(
new TinyClass(
- Arrays.asList("A", "A", "SomeClassButNamedBetter"),
+ Arrays.asList("A", "SomeClassButNamedBetter"),
Arrays.asList(),
Arrays.asList(new TinyField("a",
- Arrays.asList("a", "a", "myFieldButNamedCool"), Arrays.asList("Better comment"))),
+ Arrays.asList("a", "myFieldButNamedCool"), Arrays.asList("Better comment"))),
Arrays.asList()
),
new TinyClass(
- Arrays.asList("B", "B", "OtherClass")
+ Arrays.asList("B", "OtherClass")
)
)
);
- var merged = Zwirn.mergeTinyFile(base, overlay, "official");
- TinyV2Writer.write(merged, Path.of("out.tiny"));
}
} \ No newline at end of file