diff options
| author | 2015-02-05 23:53:41 -0500 | |
|---|---|---|
| committer | 2015-02-05 23:53:41 -0500 | |
| commit | cb22a55b241714a56f78b9c6ee863f0a37bbf005 (patch) | |
| tree | 479fa9734f472ed7b68812e6e1cde58d678b8588 /test | |
| parent | fix test code formatting (diff) | |
| download | enigma-fork-cb22a55b241714a56f78b9c6ee863f0a37bbf005.tar.gz enigma-fork-cb22a55b241714a56f78b9c6ee863f0a37bbf005.tar.xz enigma-fork-cb22a55b241714a56f78b9c6ee863f0a37bbf005.zip | |
start some translation tests
Diffstat (limited to 'test')
| -rw-r--r-- | test/cuchaz/enigma/TestTranslator.java | 39 | ||||
| -rw-r--r-- | test/cuchaz/enigma/inputs/translation/A.java | 8 | ||||
| -rw-r--r-- | test/cuchaz/enigma/resources/translation.mappings | 4 |
3 files changed, 51 insertions, 0 deletions
diff --git a/test/cuchaz/enigma/TestTranslator.java b/test/cuchaz/enigma/TestTranslator.java new file mode 100644 index 0000000..290f6f0 --- /dev/null +++ b/test/cuchaz/enigma/TestTranslator.java | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | package cuchaz.enigma; | ||
| 2 | |||
| 3 | import static cuchaz.enigma.EntryFactory.*; | ||
| 4 | import static org.hamcrest.MatcherAssert.*; | ||
| 5 | import static org.hamcrest.Matchers.*; | ||
| 6 | |||
| 7 | import java.io.InputStream; | ||
| 8 | import java.io.InputStreamReader; | ||
| 9 | import java.util.jar.JarFile; | ||
| 10 | |||
| 11 | import org.junit.Test; | ||
| 12 | |||
| 13 | import cuchaz.enigma.mapping.Mappings; | ||
| 14 | import cuchaz.enigma.mapping.MappingsReader; | ||
| 15 | import cuchaz.enigma.mapping.TranslationDirection; | ||
| 16 | import cuchaz.enigma.mapping.Translator; | ||
| 17 | |||
| 18 | |||
| 19 | public class TestTranslator { | ||
| 20 | |||
| 21 | private Deobfuscator m_deobfuscator; | ||
| 22 | private Mappings m_mappings; | ||
| 23 | |||
| 24 | public TestTranslator() | ||
| 25 | throws Exception { | ||
| 26 | m_deobfuscator = new Deobfuscator(new JarFile("build/testTranslation.obf.jar")); | ||
| 27 | try (InputStream in = getClass().getResourceAsStream("/cuchaz/enigma/resources/translation.mappings")) { | ||
| 28 | m_mappings = new MappingsReader().read(new InputStreamReader(in)); | ||
| 29 | m_deobfuscator.setMappings(m_mappings); | ||
| 30 | } | ||
| 31 | } | ||
| 32 | |||
| 33 | @Test | ||
| 34 | public void deobfuscatingTranslations() | ||
| 35 | throws Exception { | ||
| 36 | Translator translator = m_deobfuscator.getTranslator(TranslationDirection.Deobfuscating); | ||
| 37 | assertThat(translator.translateEntry(newClass("none/a")), is(newClass("deobf/A"))); | ||
| 38 | } | ||
| 39 | } | ||
diff --git a/test/cuchaz/enigma/inputs/translation/A.java b/test/cuchaz/enigma/inputs/translation/A.java new file mode 100644 index 0000000..b8aaf11 --- /dev/null +++ b/test/cuchaz/enigma/inputs/translation/A.java | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | package cuchaz.enigma.inputs.translation; | ||
| 2 | |||
| 3 | public class A { | ||
| 4 | |||
| 5 | public int one; | ||
| 6 | public float two; | ||
| 7 | public String three; | ||
| 8 | } | ||
diff --git a/test/cuchaz/enigma/resources/translation.mappings b/test/cuchaz/enigma/resources/translation.mappings new file mode 100644 index 0000000..70755bf --- /dev/null +++ b/test/cuchaz/enigma/resources/translation.mappings | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | CLASS none/a deobf/A | ||
| 2 | FIELD a one | ||
| 3 | FIELD b two | ||
| 4 | FIELD c three \ No newline at end of file | ||