diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2021-03-23 07:57:58 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2021-03-23 07:57:58 (GMT) |
commit | 8df9996699cdf96887613f99181173295a19bd76 (patch) | |
tree | 8015ff855566f9581a00630f591a919d38f7a8ec /tests | |
parent | eb470f2e5e790ba107171a3ae8c5ed27a72ed8f8 (diff) |
Create methods to deal with hex conversions.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/common/hex.py | 28 |
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) |