Sha256: 530439e191562da24e7ea96b7a23615f70c941b160537bd5c9f98db1b78da69e

Contents?: true

Size: 1.36 KB

Versions: 127

Compression:

Stored size: 1.36 KB

Contents

import unittest

from secret_handshake import handshake, code


class HandshakeTest(unittest.TestCase):
    def test_shake_int(self):
        self.assertEqual(['wink', 'jump'], handshake(9))

    def test_shake_bin1(self):
        self.assertEqual(['close your eyes', 'double blink'], handshake('10110'))

    def test_shake_bin2(self):
        self.assertEqual(['wink', 'close your eyes'], handshake('101'))

    def test_shake_negative_int(self):
        self.assertEqual([], handshake(-9))

    def test_shake_bin_invalid(self):
        self.assertEqual([], handshake('121'))

    def test_unknown_action(self):
        self.assertEqual('0', code(['wink', 'sneeze']))

    def test_code1(self):
        self.assertEqual('1100', code(['close your eyes', 'jump']))

    def test_code2(self):
        self.assertEqual('11', code(['wink', 'double blink']))

    def test_code3(self):
        self.assertEqual('11010', code(['jump', 'double blink']))

    def test_composition1(self):
        self.assertEqual('11011', code(handshake(27)))

    def test_composition2(self):
        self.assertEqual('1', code(handshake(1)))

    def test_composition3(self):
        self.assertEqual('111', code(handshake('111')))

    def test_composition4(self):
        inp = ['wink', 'double blink', 'jump']
        self.assertEqual(inp, handshake(code(inp)))


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/secret-handshake/secret_handshake_test.py
trackler-2.0.8.26 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.0.8.24 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.0.8.23 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.0.8.22 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.0.8.21 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.0.8.20 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.0.8.19 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.0.8.18 tracks/python/exercises/secret-handshake/handshake_test.py
trackler-2.0.8.17 tracks/python/exercises/secret-handshake/handshake_test.py
trackler-2.0.8.16 tracks/python/exercises/secret-handshake/handshake_test.py
trackler-2.0.8.15 tracks/python/exercises/secret-handshake/handshake_test.py
trackler-2.0.8.14 tracks/python/exercises/secret-handshake/handshake_test.py
trackler-2.0.8.13 tracks/python/exercises/secret-handshake/handshake_test.py
trackler-2.0.8.12 tracks/python/exercises/secret-handshake/handshake_test.py
trackler-2.0.8.11 tracks/python/exercises/secret-handshake/handshake_test.py
trackler-2.0.8.10 tracks/python/exercises/secret-handshake/handshake_test.py
trackler-2.0.8.9 tracks/python/exercises/secret-handshake/handshake_test.py
trackler-2.0.8.8 tracks/python/exercises/secret-handshake/handshake_test.py
trackler-2.0.8.7 tracks/python/exercises/secret-handshake/handshake_test.py