-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_q3.py
63 lines (53 loc) · 2.8 KB
/
test_q3.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
51
52
53
54
55
56
57
58
59
60
61
62
63
import unittest
from q3_logic import *
# Weird spectrum just for testing
BWG = [Color.black, Color.white, Color.green]
class Test_1_Monochrome(unittest.TestCase):
def test_1_full_bw(self):
grid = Grid([[Color.black, Color.white, Color.black],
[Color.black, Color.white, Color.white]])
self.assertTrue(grid.some_column_all_colors(BW))
self.assertFalse(grid.some_column_all_colors(BWG))
def test_2_not_in_column(self):
grid = Grid([[Color.black, Color.white, Color.black],
[Color.black, Color.white, Color.black]])
self.assertFalse(grid.some_column_all_colors(BW))
def test_3_long_columns(self):
grid = Grid([[Color.black, Color.white, Color.white],
[Color.black, Color.white, Color.white],
[Color.black, Color.white, Color.white],
[Color.black, Color.white, Color.white],
[Color.black, Color.white, Color.white],
[Color.black, Color.black, Color.white],
])
self.assertTrue(grid.some_column_all_colors(BW))
self.assertFalse(grid.some_column_all_colors(BWG))
class Test_2_Rainbow(unittest.TestCase):
def test_1_rainbow(self):
# A grid with full rainbow of colors in third column
grid = Grid(
[[Color.red, Color.green, Color.red, Color.red]
,[Color.green, Color.red, Color.green, Color.green]
,[Color.blue, Color.orange, Color.blue, Color.orange]
,[Color.orange, Color.blue, Color.orange, Color.blue]
,[Color.indigo, Color.violet, Color.indigo, Color.violet]
,[Color.indigo, Color.yellow, Color.violet, Color.violet]
,[Color.blue, Color.green, Color.yellow, Color.yellow]
,[Color.red, Color.green, Color.red, Color.red]])
self.assertTrue(grid.some_column_all_colors(RAINBOW))
self.assertFalse(grid.some_column_all_colors(BW))
def test_2_rainbow(self):
# No single column has all the rainbow colors
grid = Grid([[Color.red, Color.green, Color.red, Color.red]
,[Color.green, Color.red, Color.green, Color.green]
,[Color.blue, Color.orange, Color.blue, Color.orange]
,[Color.orange, Color.blue, Color.orange, Color.blue]
,[Color.indigo, Color.violet, Color.indigo, Color.violet]
,[Color.indigo, Color.violet, Color.yellow, Color.violet]
,[Color.blue, Color.green, Color.red, Color.yellow]
,[Color.red, Color.green, Color.yellow, Color.red]])
self.assertFalse(grid.some_column_all_colors(RAINBOW))
# But several columns have at least the primary colors
self.assertTrue(grid.some_column_all_colors(PRIMARIES))
if __name__ == "__main__":
unittest.main()