From 72176117bf75866fc702bbb094e7adc6661f2b01 Mon Sep 17 00:00:00 2001 From: Toshimichi0915 Date: Sun, 12 Jun 2022 21:24:41 +0900 Subject: Add Recaf format support (#451) * Add Recaf format support * Update language files Co-authored-by: 2xsaiko --- .../translation/mapping/serde/recaf/TestRecaf.java | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 enigma/src/test/java/cuchaz/enigma/translation/mapping/serde/recaf/TestRecaf.java (limited to 'enigma/src/test/java') 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 @@ +package cuchaz.enigma.translation.mapping.serde.recaf; + +import com.google.common.collect.Sets; +import com.google.common.jimfs.Jimfs; +import cuchaz.enigma.ProgressListener; +import cuchaz.enigma.translation.mapping.EntryMapping; +import cuchaz.enigma.translation.mapping.tree.EntryTree; +import org.junit.Test; + +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.nio.file.FileSystem; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.HashSet; +import java.util.Set; + +import static org.junit.Assert.assertEquals; + +public class TestRecaf { + + @Test + public void testIntegrity() throws Exception { + Set contents; + try (InputStream in = getClass().getResourceAsStream("/recaf.mappings")) { + contents = Sets.newHashSet(new String(in.readAllBytes(), StandardCharsets.UTF_8).split("\\R")); + } + + try (FileSystem fs = Jimfs.newFileSystem()) { + + Path path = fs.getPath("recaf.mappings"); + Files.writeString(path, String.join("\n", contents)); + + RecafMappingsWriter writer = RecafMappingsWriter.INSTANCE; + RecafMappingsReader reader = RecafMappingsReader.INSTANCE; + + EntryTree mappings = reader.read(path, ProgressListener.none(), null); + writer.write(mappings, path, ProgressListener.none(), null); + + reader.read(path, ProgressListener.none(), null); + Set newContents = new HashSet<>(Files.readAllLines(path)); + + assertEquals(contents, newContents); + } + } +} -- cgit v1.2.3