diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2018-12-18 22:54:36 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2018-12-18 22:54:36 (GMT) |
commit | b8a99266e691ec5a2a13f10d6c775f4bdc0dbbc2 (patch) | |
tree | f18a43a0af5f0f2221c171c4d92a3c057102a600 /tests | |
parent | 706710aef28a0af4bb8aa343c2631a2139d00955 (diff) |
Made Python constant values storable using Pickle.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/constval.py | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/tests/constval.py b/tests/constval.py index 4863d39..eafb8d3 100644 --- a/tests/constval.py +++ b/tests/constval.py @@ -5,18 +5,40 @@ from chrysacase import ChrysalideTestCase from pychrysalide import PyConstvalObject from pychrysalide.arch import ArchInstruction +import pickle class TestConstVal(ChrysalideTestCase): """TestCase for PyConstvalObject.""" - def testGI(self): - """Validate the PyConstvalObject implementation.""" + def testCreation(self): + """Validate PyConstvalObject creation from Python.""" + + cst = PyConstvalObject(123, 'XXX') + + self.assertEqual(cst, 123) + + self.assertEqual(str(cst), 'XXX') - with self.assertRaises(RuntimeError): - cv = PyConstvalObject() + + def testString(self): + """Validate the PyConstvalObject implementation.""" self.assertEqual(ArchInstruction.ILT_JUMP, 1) self.assertEqual(str(ArchInstruction.ILT_JUMP), 'ILT_JUMP') + + + def testStorage(self): + """Ensure PyConstvalObject instances are storable.""" + + cst = ArchInstruction.ILT_JUMP + + data = pickle.dumps(cst) + + cst = pickle.loads(data) + + self.assertEqual(cst, ArchInstruction.ILT_JUMP) + + self.assertEqual(str(cst), 'ILT_JUMP') |