-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
99 lines (75 loc) · 2.61 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
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import pytest
from oop_variant import TreasureHunt
from functional_variant import find_way, hunt_treasure
def test_oop_implementation_1():
matrix = [[55, 14, 25, 52, 21],
[44, 31, 11, 53, 43],
[24, 13, 45, 12, 34],
[42, 22, 43, 32, 41],
[51, 23, 33, 54, 15]]
obj = TreasureHunt(matrix)
clues = obj.calculate()
obj.print_result(clues)
assert type(clues) == list
assert len(clues) == 9
assert clues == [11, 55, 15, 21, 44, 32, 13, 25, 43]
def test_oop_implementation_2():
matrix = [[11, 14, 25, 52, 21],
[44, 31, 11, 53, 43],
[24, 13, 45, 12, 34],
[42, 22, 43, 32, 41],
[51, 23, 33, 54, 15]]
obj = TreasureHunt(matrix)
clues = obj.calculate()
assert clues == [11]
assert len(clues) == 1
assert type(clues) == list
def test_oop_implementation_3():
matrix = [11, 14, 25, 52, 21]
obj = TreasureHunt(matrix)
clues = obj.calculate()
assert obj.matrix is None
assert clues == "Given false matrix"
assert type(clues) == str
assert obj.print_result(clues) == "Given false matrix"
def test_oop_implementation_4():
matrix = 12
obj = TreasureHunt(matrix)
clues = obj.calculate()
assert obj.matrix is None
assert clues == "Given false matrix"
assert type(clues) == str
assert obj.print_result(clues) == "Given false matrix"
def test_functional_implementation_1():
matrix = [[55, 14, 25, 52, 21],
[44, 31, 11, 53, 43],
[24, 13, 45, 12, 34],
[42, 22, 43, 32, 41],
[51, 23, 33, 54, 15]]
res_data = find_way(matrix)
assert type(res_data) == list
assert len(res_data) == 9
assert res_data == [11, 55, 15, 21, 44, 32, 13, 25, 43]
def test_functional_implementation_2():
matrix = [[11, 14, 25, 52, 21],
[44, 31, 11, 53, 43],
[24, 13, 45, 12, 34],
[42, 22, 43, 32, 41],
[51, 23, 33, 54, 15]]
res_data = find_way(matrix)
hunt_treasure(matrix)
assert res_data == [11]
assert len(res_data) == 1
assert type(res_data) == list
def test_functional_implementation_3():
matrix = [11, 14, 25, 52, 21]
res_data = find_way(matrix)
assert res_data == "Invalid data received"
assert type(res_data) == str
assert hunt_treasure(matrix) == "Invalid data received"
def test_functional_implementation_4():
matrix = 12
res_data = find_way(matrix)
assert res_data == "Invalid data received"
assert type(res_data) == str
assert hunt_treasure(matrix) == "Invalid data received"