Sha256: ff7d20fed5987fc096b636f2bcb57f110b2320e10264775409a48645675249e1

Contents?: true

Size: 1.01 KB

Versions: 127

Compression:

Stored size: 1.01 KB

Contents

# To avoid trivial solutions, try to solve this problem without the
# function int(s, base=16)

import unittest

from hexadecimal import hexa


class HexadecimalTest(unittest.TestCase):

    def test_valid_hexa1(self):
        self.assertEqual(1, hexa('1'))

    def test_valid_hexa2(self):
        self.assertEqual(12, hexa('c'))

    def test_valid_hexa3(self):
        self.assertEqual(16, hexa('10'))

    def test_valid_hexa4(self):
        self.assertEqual(175, hexa('af'))

    def test_valid_hexa5(self):
        self.assertEqual(256, hexa('100'))

    def test_valid_hexa6(self):
        self.assertEqual(105166, hexa('19ACE'))

    def test_valid_hexa7(self):
        self.assertEqual(0, hexa('000000'))

    def test_valid_hexa8(self):
        self.assertEqual(16776960, hexa('ffff00'))

    def test_valid_hexa9(self):
        self.assertEqual(65520, hexa('00fff0'))

    def test_invalid_hexa(self):
        with self.assertRaises(ValueError):
            hexa('carrot')


if __name__ == '__main__':
    unittest.main()

Version data entries

127 entries across 127 versions & 1 rubygems

Version Path
trackler-2.0.8.27 tracks/python/exercises/hexadecimal/hexadecimal_test.py
trackler-2.0.8.26 tracks/python/exercises/hexadecimal/hexadecimal_test.py
trackler-2.0.8.24 tracks/python/exercises/hexadecimal/hexadecimal_test.py
trackler-2.0.8.23 tracks/python/exercises/hexadecimal/hexadecimal_test.py
trackler-2.0.8.22 tracks/python/exercises/hexadecimal/hexadecimal_test.py
trackler-2.0.8.21 tracks/python/exercises/hexadecimal/hexadecimal_test.py
trackler-2.0.8.20 tracks/python/exercises/hexadecimal/hexadecimal_test.py
trackler-2.0.8.19 tracks/python/exercises/hexadecimal/hexadecimal_test.py
trackler-2.0.8.18 tracks/python/exercises/hexadecimal/hexadecimal_test.py
trackler-2.0.8.17 tracks/python/exercises/hexadecimal/hexadecimal_test.py
trackler-2.0.8.16 tracks/python/exercises/hexadecimal/hexadecimal_test.py
trackler-2.0.8.15 tracks/python/exercises/hexadecimal/hexadecimal_test.py
trackler-2.0.8.14 tracks/python/exercises/hexadecimal/hexadecimal_test.py
trackler-2.0.8.13 tracks/python/exercises/hexadecimal/hexadecimal_test.py
trackler-2.0.8.12 tracks/python/exercises/hexadecimal/hexadecimal_test.py
trackler-2.0.8.11 tracks/python/exercises/hexadecimal/hexadecimal_test.py
trackler-2.0.8.10 tracks/python/exercises/hexadecimal/hexadecimal_test.py
trackler-2.0.8.9 tracks/python/exercises/hexadecimal/hexadecimal_test.py
trackler-2.0.8.8 tracks/python/exercises/hexadecimal/hexadecimal_test.py
trackler-2.0.8.7 tracks/python/exercises/hexadecimal/hexadecimal_test.py