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.2.1.67 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.2.1.66 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.2.1.65 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.2.1.64 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.2.1.63 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.2.1.62 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.2.1.61 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.2.1.60 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.2.1.59 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.2.1.58 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.2.1.57 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.2.1.56 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.2.1.55 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.2.1.54 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.2.1.53 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.2.1.52 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.2.1.51 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.2.1.50 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.2.1.49 tracks/python/exercises/secret-handshake/secret_handshake_test.py
trackler-2.2.1.48 tracks/python/exercises/secret-handshake/secret_handshake_test.py