-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
35 lines (29 loc) · 853 Bytes
/
test.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
import unittest
from post import PostMachine
class TestPostMachine(unittest.TestCase):
def test_run_case1(self):
pm = PostMachine()
pm.add_command(">")
pm.add_command("0")
pm.add_command("? 3 5")
pm.add_command("1")
pm.run()
self.assertEqual(pm.get_tape(), "001")
def test_run_case2(self):
pm = PostMachine()
pm.add_command(">")
pm.add_command("1")
pm.add_command("? 3 5")
pm.add_command("0")
pm.run()
self.assertEqual(pm.get_tape(), "010")
def test_run_case3(self):
pm = PostMachine()
pm.add_command(">")
pm.add_command("? 3 5")
pm.add_command("0")
pm.add_command("1")
pm.run()
self.assertEqual(pm.get_tape(), "010")
if __name__ == '__main__':
unittest.main()