summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2020-02-18 22:24:55 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2020-02-18 22:24:55 (GMT)
commitd6b2e6639698674cbdaf7dc2e5f5a637abcfadb0 (patch)
tree13394ab4695d8f4b60195961f24dd498c6bcbbe6 /tests
parent95e204291faa4800781d2f302c41f86a3f01851d (diff)
Relocated the raw instructions.
Diffstat (limited to 'tests')
-rw-r--r--tests/arch/raw.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/arch/raw.py b/tests/arch/raw.py
new file mode 100644
index 0000000..05d7435
--- /dev/null
+++ b/tests/arch/raw.py
@@ -0,0 +1,32 @@
+#!/usr/bin/python3-dbg
+# -*- coding: utf-8 -*-
+
+
+import pychrysalide
+from chrysacase import ChrysalideTestCase
+from pychrysalide.analysis import BinContent
+from pychrysalide.analysis.contents import MemoryContent
+from pychrysalide.arch import vmpa
+from pychrysalide.arch.instructions import RawInstruction
+
+
+class TestRawInstruction(ChrysalideTestCase):
+ """TestCase for arch.instructions.RawInstruction."""
+
+ def testConstructors(self):
+ """Build some raw instructions to check their constructors."""
+
+ instr = RawInstruction(vmpa(0), BinContent.MemoryDataSize._32_BITS_UNSIGNED, value=123)
+ self.assertIsNotNone(instr)
+
+ data = b'\x01\x02\x03\x04\x05\x06\x07\x08'
+ cnt = MemoryContent(data)
+
+ instr = RawInstruction(vmpa(0), BinContent.MemoryDataSize._32_BITS_UNSIGNED,
+ content=cnt, count=2, endian=BinContent.SourceEndian.LITTLE)
+ self.assertIsNotNone(instr)
+
+ with self.assertRaisesRegex(Exception, 'Unable to build the object with the given parameters.'):
+
+ instr = RawInstruction(vmpa(0), BinContent.MemoryDataSize._32_BITS_UNSIGNED,
+ content=cnt, count=3, endian=BinContent.SourceEndian.LITTLE)