Sha256: fb0fe16c8d44793156e02e87af0cfb43b49c946ebda02d5e7fc949102ce7a2c0

Contents?: true

Size: 1.37 KB

Versions: 178

Compression:

Stored size: 1.37 KB

Contents

import unittest

from secret_handshake import handshake, code


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

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

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

    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(code(['wink', 'sneeze']), '0')

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

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

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

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

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

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

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


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

Version data entries

178 entries across 178 versions & 1 rubygems

Version Path
trackler-2.0.8.45 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.0.8.44 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.0.8.43 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.0.8.42 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.0.8.41 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.0.8.40 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.0.8.39 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.0.8.38 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.0.8.37 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.0.8.36 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.0.8.35 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.0.8.34 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.0.8.33 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.0.8.32 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.0.8.31 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.0.8.30 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.0.8.29 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.0.8.28 tracks/python/exercises/secret-handshake/secret_handshake_test.py