-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
35 lines (27 loc) · 1.2 KB
/
tests.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 subprocess
import unittest
class TestBasicIO(unittest.TestCase):
def check_output(self, command: str, expected: str):
result = subprocess.run(["./a.out", command], capture_output=True)
self.assertEqual(expected, result.stdout.decode())
def test_letter_h(self):
command = "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++."
self.check_output(command, "H")
def test_basic_loop(self):
command = "+++[-]"
self.check_output(command, "")
def test_intermediate_loop(self):
command = "++++++[--]"
self.check_output(command, "")
def test_letter_h_loops(self):
command = ">++++++++[<+++++++++>-]<."
self.check_output(command, "H")
class TestIntegration(unittest.TestCase):
check_output = TestBasicIO.check_output
def test_hello_world(self):
command = (">++++++++[<+++++++++>-]<.>++++[<+++++++>-]<+.+++++++..+++.>>++++++[<+++++++>-]<+"
+ "+.------------.>++++++[<+++++++++>-]<+.<.+++.------.--------.>>>++++[<++++++++>-"
+ "]<+.")
self.check_output(command, "Hello, World!")
if __name__ == "__main__":
unittest.main()