summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/common/hex.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/common/hex.py b/tests/common/hex.py
new file mode 100644
index 0000000..f76b6a8
--- /dev/null
+++ b/tests/common/hex.py
@@ -0,0 +1,28 @@
+
+from chrysacase import ChrysalideTestCase
+from pychrysalide.common import encode_hex, decode_hex_digit
+
+
+class TestHexValues(ChrysalideTestCase):
+ """TestCase for common hexadecimal features*"""
+
+ def testHexEncoding(self):
+ """Convert data to hex string."""
+
+ ref = b'ABC'
+
+ self.assertEqual(encode_hex(ref), ref.hex())
+
+ ref = 'ABC'
+
+ self.assertEqual(encode_hex(ref), bytes(ref, 'ascii').hex())
+
+ ref = 'ABC'
+
+ self.assertEqual(encode_hex(ref, False), bytes(ref, 'ascii').hex().upper())
+
+
+ def testHexDecoding(self):
+ """Convert a hex string to value."""
+
+ self.assertEqual(decode_hex_digit('A'), 0xa)