summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-03-11 21:57:05 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-03-11 21:57:05 (GMT)
commit8088f1cbb4304c686ff41520099707a333084a4e (patch)
tree147411c3f90097dc1ae950ec390df2dfccf07ad7 /tests
parenta33dd28e763e3a8b04145fb549aca9320e100a4b (diff)
Defined a new Dex demangler with MUTF-8 support as plugin.
Diffstat (limited to 'tests')
-rw-r--r--tests/mangling/dex.py66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/mangling/dex.py b/tests/mangling/dex.py
new file mode 100644
index 0000000..ad60953
--- /dev/null
+++ b/tests/mangling/dex.py
@@ -0,0 +1,66 @@
+#!/usr/bin/python3-dbg
+# -*- coding: utf-8 -*-
+
+
+# Tests validant le décodage des types et des routines pour le format Dex
+
+
+from chrysacase import ChrysalideTestCase
+from pychrysalide.mangling import DexDemangler
+
+
+class TestDexMangling(ChrysalideTestCase):
+ """TestCase for pychrysalide.mangling.DexDemangler."""
+
+ def check_demangling(self, got, expected):
+ """Check a given demangling result."""
+
+ self.assertTrue(str(got) == expected)
+
+
+ def testDexTypeMangling(self):
+ """Check Dex type demangling."""
+
+ demangler = DexDemangler()
+
+ demangled = demangler.decode_type('V')
+ self.check_demangling(demangled, 'void')
+
+ demangled = demangler.decode_type('[I')
+ self.check_demangling(demangled, 'int []')
+
+ demangled = demangler.decode_type('[[I')
+ self.check_demangling(demangled, 'int [][]')
+
+ demangled = demangler.decode_type('Ltoto;')
+ self.check_demangling(demangled, 'toto')
+
+ demangled = demangler.decode_type('Ltiti/toto/tata;')
+ self.check_demangling(demangled, 'tata')
+
+
+ def testDexBadTypeMangling(self):
+ """Check Dex malformed type mangling."""
+
+ demangler = DexDemangler()
+
+ demangled = demangler.decode_type('Ltiti/toto/tata/;')
+ self.assertIsNone(demangled)
+
+
+ def testDexRoutineMangling(self):
+ """Check Dex routine demangling."""
+
+ demangler = DexDemangler()
+
+ demangled = demangler.decode_routine('I')
+ self.check_demangling(demangled, 'int ()')
+
+
+ def testDexBadRoutineMangling(self):
+ """Check Dex malformed routine mangling."""
+
+ demangler = DexDemangler()
+
+ demangled = demangler.decode_routine('IX')
+ self.assertIsNone(demangled)