diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2020-05-18 21:50:26 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2020-05-18 21:50:26 (GMT) |
commit | 041056d04032d41a5c092c62cbfd67b199094991 (patch) | |
tree | a294afa55e307fe68617f80af3e9999ad7fa28b6 /tests/format | |
parent | 4f18f051936f633473c365d4c91ef7e77fa7feee (diff) |
Updated the Python API for string symbols.
Diffstat (limited to 'tests/format')
-rw-r--r-- | tests/format/strsym.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/format/strsym.py b/tests/format/strsym.py new file mode 100644 index 0000000..ba1d92f --- /dev/null +++ b/tests/format/strsym.py @@ -0,0 +1,33 @@ + +from chrysacase import ChrysalideTestCase +from pychrysalide.analysis import BinContent +from pychrysalide.analysis.contents import MemoryContent +from pychrysalide.arch import vmpa, mrange +from pychrysalide.format import FlatFormat, StrSymbol + + +class TestBinarySymbols(ChrysalideTestCase): + """TestCase for format.StrSymbol.""" + + def testStringSymbolConstructors(self): + """Build string symbols.""" + + data = b'ABCD1234' + + cnt = MemoryContent(data) + fmt = FlatFormat(cnt, 'xxx', BinContent.SourceEndian.LITTLE) + + saddr = vmpa(0x0, vmpa.VmpaSpecialValue.NO_VIRTUAL) + srange = mrange(saddr, 0x5) + + symbol = StrSymbol(StrSymbol.StringEncodingType.GUESS, fmt, srange) + + self.assertEqual(symbol.raw, b'ABCD1') + self.assertEqual(symbol.utf8, 'ABCD1') + self.assertEqual(symbol.encoding, StrSymbol.StringEncodingType.ASCII) + + symbol = StrSymbol(StrSymbol.StringEncodingType.GUESS, string='abcdef', addr=saddr) + + self.assertEqual(symbol.raw, b'abcdef') + self.assertEqual(symbol.utf8, 'abcdef') + self.assertEqual(symbol.encoding, StrSymbol.StringEncodingType.ASCII) |