summaryrefslogtreecommitdiff
path: root/enigma/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'enigma/src/test/java')
-rw-r--r--enigma/src/test/java/cuchaz/enigma/translation/mapping/serde/recaf/TestRecaf.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/enigma/src/test/java/cuchaz/enigma/translation/mapping/serde/recaf/TestRecaf.java b/enigma/src/test/java/cuchaz/enigma/translation/mapping/serde/recaf/TestRecaf.java
new file mode 100644
index 0000000..1026f57
--- /dev/null
+++ b/enigma/src/test/java/cuchaz/enigma/translation/mapping/serde/recaf/TestRecaf.java
@@ -0,0 +1,46 @@
1package cuchaz.enigma.translation.mapping.serde.recaf;
2
3import com.google.common.collect.Sets;
4import com.google.common.jimfs.Jimfs;
5import cuchaz.enigma.ProgressListener;
6import cuchaz.enigma.translation.mapping.EntryMapping;
7import cuchaz.enigma.translation.mapping.tree.EntryTree;
8import org.junit.Test;
9
10import java.io.InputStream;
11import java.nio.charset.StandardCharsets;
12import java.nio.file.FileSystem;
13import java.nio.file.Files;
14import java.nio.file.Path;
15import java.util.HashSet;
16import java.util.Set;
17
18import static org.junit.Assert.assertEquals;
19
20public class TestRecaf {
21
22 @Test
23 public void testIntegrity() throws Exception {
24 Set<String> contents;
25 try (InputStream in = getClass().getResourceAsStream("/recaf.mappings")) {
26 contents = Sets.newHashSet(new String(in.readAllBytes(), StandardCharsets.UTF_8).split("\\R"));
27 }
28
29 try (FileSystem fs = Jimfs.newFileSystem()) {
30
31 Path path = fs.getPath("recaf.mappings");
32 Files.writeString(path, String.join("\n", contents));
33
34 RecafMappingsWriter writer = RecafMappingsWriter.INSTANCE;
35 RecafMappingsReader reader = RecafMappingsReader.INSTANCE;
36
37 EntryTree<EntryMapping> mappings = reader.read(path, ProgressListener.none(), null);
38 writer.write(mappings, path, ProgressListener.none(), null);
39
40 reader.read(path, ProgressListener.none(), null);
41 Set<String> newContents = new HashSet<>(Files.readAllLines(path));
42
43 assertEquals(contents, newContents);
44 }
45 }
46}