/
test_shortest_path.py
50 lines (38 loc) · 1.45 KB
/
test_shortest_path.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import keyboard_shortest_path as ksp
import unittest
class test_shortest_path(unittest.TestCase):
def setUp(self):
pass
def test_zebra_3x9(self):
rows = 3
columns = 9
commands = ksp.shortest_path(rows, columns, 'jeff')
self.assertEqual(commands, [(1, 0), (-1, 4), (0, 1), (0, 0)])
word = ksp.commands_to_word(rows, columns, commands)
print word
self.assertEqual(word, 'jeff')
commands = ksp.shortest_path(rows, columns, 'zebra')
self.assertEqual(commands,
[(-1, -2), (1, -3), (0, -3), (1, -2), (-1, 1)])
word = ksp.commands_to_word(rows, columns, commands)
print word
self.assertEqual(word, 'zebra')
ksp.print_keyboard(ksp.make_keyboard(rows, columns))
def test_zebra_1x28(self):
rows = 1
columns = 28
commands = ksp.shortest_path(rows, columns, 'zebra')
word = ksp.commands_to_word(rows, columns, commands)
print word
self.assertEqual(word, 'zebra')
ksp.print_keyboard(ksp.make_keyboard(rows, columns))
def test_zebra_9x3(self):
rows = 9
columns = 3
commands = ksp.shortest_path(rows, columns, 'zebra')
word = ksp.commands_to_word(rows, columns, commands)
print word
self.assertEqual(word, 'zebra')
ksp.print_keyboard(ksp.make_keyboard(rows, columns))
if __name__ == '__main__':
unittest.main()