summaryrefslogtreecommitdiff
path: root/tests/common
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2023-04-21 04:28:03 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2023-04-21 04:28:03 (GMT)
commitf06602ac36b4ad7974d836aad76ed236a7a0c942 (patch)
treeaff72fc133156f8eba5d3593311dd01284b1a5ec /tests/common
parentf07044dab60fcd74ee32f4f959f7c2a233153bfa (diff)
Implement the itoa() non-standard function.
Diffstat (limited to 'tests/common')
-rw-r--r--tests/common/itoa.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/common/itoa.py b/tests/common/itoa.py
new file mode 100644
index 0000000..a004cbd
--- /dev/null
+++ b/tests/common/itoa.py
@@ -0,0 +1,28 @@
+
+from chrysacase import ChrysalideTestCase
+from pychrysalide.common import itoa
+
+
+class TestItoa(ChrysalideTestCase):
+ """TestCase for calls to the itoa() implementation."""
+
+ def testItoaCallss(self):
+ """Convert some integer values into strings."""
+
+ val = itoa(123, 10)
+ self.assertEqual(val, '123')
+
+ val = itoa(-123, 10)
+ self.assertEqual(val, '-123')
+
+ val = itoa(0, 10)
+ self.assertEqual(val, '0')
+
+ val = itoa(0, 2)
+ self.assertEqual(val, '0')
+
+ val = itoa(127, 2)
+ self.assertEqual(val, '1111111')
+
+ val = itoa(101, 2)
+ self.assertEqual(val, '1100101')