Test Setup Failed
Push — master ( 7bb22c...828255 )
by Ken M.
01:06
created

Tests.test_Edge()   A

Complexity

Conditions 3

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 3
c 3
b 0
f 0
dl 0
loc 3
rs 10
1
import unittest
2
3
from pawn_brotherhood import safe_pawns
4
5
6
class Tests(unittest.TestCase):
7
    TESTS = {
8
        "Basics": [
9
            {
10
                "input": ["b4", "d4", "f4", "c3", "e3", "g5", "d2"],
11
                "answer": 6,
12
                "explanation": ["d2"]
13
            },
14
            {
15
                "input": ["b4", "c4", "d4", "e4", "f4", "g4", "e5"],
16
                "answer": 1,
17
                "explanation": ["b4", "c4", "d4", "e4", "f4", "g4"]
18
            },
19
        ],
20
        "Edge": [
21
            {
22
                "input": ["e4"],
23
                "answer": 0,
24
                "explanation": ["e4"]
25
            },
26
            {
27
                "input": ["e8"],
28
                "answer": 0,
29
                "explanation": ["e8"]
30
            },
31
            {
32
                "input": ["a1", "b2", "c3", "d4", "e5", "f6", "g7", "h8"],
33
                "answer": 7,
34
                "explanation": ["a1"]
35
            },
36
            {
37
                "input": ["a8", "b7", "c6", "d5", "e4", "f3", "g2", "h1"],
38
                "answer": 7,
39
                "explanation": ["h1"]
40
            },
41
            {
42
                "input": ["a1", "b2", "c3", "d4", "e5", "f6", "g7", "h8"],
43
                "answer": 7,
44
                "explanation": ["a1"]
45
            },
46
            {
47
                "input": ["a2", "b2", "c2", "d2", "e2", "f2", "g2", "h2"],
48
                "answer": 0,
49
                "explanation": ["a2", "b2", "c2", "d2", "e2", "f2", "g2", "h2"]
50
            },
51
            {
52
                "input": ["a1", "a2", "a3", "a4", "h1", "h2", "h3", "h4"],
53
                "answer": 0,
54
                "explanation": ["a1", "a2", "a3", "a4", "h1", "h2", "h3", "h4"]
55
            },
56
        ],
57
        "Extra": [
58
            {
59
                "input": ["b4", "c4", "d4", "e4", "f4", "g4", "e3"],
60
                "answer": 2,
61
                "explanation": ["b4", "c4", "e4", "g4", "e3"]
62
            },
63
            {
64
                "input": ["e7", "e6", "d5", "f5", "c4", "e4", "g4", "e8"],
65
                "answer": 3,
66
                "explanation": ["e8", "e7", "c4", "e4", "g4"]
67
            },
68
            {
69
                "input": ["a2", "b4", "c6", "d8", "e1", "f3", "g5", "h8"],
70
                "answer": 0,
71
                "explanation": ["a2", "b4", "c6", "d8", "e1", "f3", "g5", "h8"]
72
            },
73
            {
74
                "input": ["b6", "a7", "b8", "c7", "g1", "f2", "h2", "g3"],
75
                "answer": 6,
76
                "explanation": ["b6", "g1"]
77
            },
78
        ]
79
    }
80
81
    def test_Basics(self):
82
        for i in self.TESTS['Basics']:
83
            assert safe_pawns(i['input']) == i['answer'], i['input']
84
85
    def test_Edge(self):
86
        for i in self.TESTS['Edge']:
87
            assert safe_pawns(i['input']) == i['answer'], i['input']
88
89
    def test_Extra(self):
90
        for i in self.TESTS['Extra']:
91
            assert safe_pawns(i['input']) == i['answer'], i['input']
92
93
94
if __name__ == "__main__":  # pragma: no cover
95
    unittest.main()
96