aboutsummaryrefslogtreecommitdiffstats
path: root/src/shorturls/tests/test_baseconv.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/shorturls/tests/test_baseconv.py')
-rw-r--r--src/shorturls/tests/test_baseconv.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/shorturls/tests/test_baseconv.py b/src/shorturls/tests/test_baseconv.py
new file mode 100644
index 0000000..5e203b7
--- /dev/null
+++ b/src/shorturls/tests/test_baseconv.py
@@ -0,0 +1,19 @@
+import unittest
+from shorturls import baseconv
+
+class BaseConvTests(unittest.TestCase):
+
+ def _test_converter(self, converter):
+ nums = [-10 ** 10, 10 ** 10] + range(-100, 100)
+ for before in nums:
+ after = converter.to_decimal(converter.from_decimal(before))
+ self.assertEqual(before, after)
+
+ def test_bin(self):
+ self._test_converter(baseconv.bin)
+
+ def test_hex(self):
+ self._test_converter(baseconv.hexconv)
+
+ def test_base62(self):
+ self._test_converter(baseconv.base62) \ No newline at end of file