Commit 57f0ff3021104dec7adaedd9534f96bdcde22f02
1 parent
88ef702c
Full unit testing coverage
Showing
2 changed files
with
42 additions
and
2 deletions
Show diff stats
structure.py
... | ... | @@ -14,7 +14,11 @@ class RSSVector(): |
14 | 14 | self.n2 = n2 |
15 | 15 | self.n3 = n3 |
16 | 16 | self.n4 = n4 |
17 | - | |
17 | + | |
18 | + def __eq__(self, v2): | |
19 | + return True if v2.n1 == self.n1 and v2.n2 == self.n2 \ | |
20 | + and v2.n3 == self.n3 and v2.n4 == self.n4 else False | |
21 | + | |
18 | 22 | class Location(): |
19 | 23 | def __init__(self, x, y, z=0): |
20 | 24 | self.x = x | ... | ... |
test_structure.py
... | ... | @@ -39,4 +39,40 @@ def test_MarkovModel(): |
39 | 39 | test_MM.moveToCellID(3) |
40 | 40 | assert test_MM.previousCell == 3 |
41 | 41 | test_MM.moveToCell(Tf[0][1]) |
42 | - assert test_MM.previousCell == 2 | |
43 | 42 | \ No newline at end of file |
43 | + assert test_MM.previousCell == 2 | |
44 | + | |
45 | +def test_newCell(): | |
46 | + testCell = newCell(-38,-27,-54,-13,2,2) | |
47 | + assert testCell.location == Location(2,2) | |
48 | + assert testCell.v == RSSVector(-38,-27,-54,-13) | |
49 | + | |
50 | +def test_Path(): | |
51 | + test_MM = MarkovModel(Tf) | |
52 | + assert test_MM.previousCell == 0 | |
53 | + test_MM.path([1,2,3,4]) | |
54 | + assert test_MM.previousCell == 4 | |
55 | + test_MM.path([8,4,4]) | |
56 | + assert test_MM.previousCell == 4 | |
57 | + | |
58 | +def test_getPositionInArray(): | |
59 | + test_loc = Location(2,2) | |
60 | + assert test_loc.getPositionInArray() == 0 | |
61 | + test_loc = Location(2,6) | |
62 | + assert test_loc.getPositionInArray() == 1 | |
63 | + test_loc = Location(10,10) | |
64 | + assert test_loc.getPositionInArray() == 8 | |
65 | + | |
66 | +def test_fromID(): | |
67 | + test_loc = Location.fromID(3) | |
68 | + assert test_loc == Location(2,10) | |
69 | + test_loc = Location.fromID(9) | |
70 | + assert test_loc == Location(10,10) | |
71 | + | |
72 | +def test_getModeLikely(): | |
73 | + test_MM = MarkovModel(Tf) | |
74 | + test_MM.path([1,2,3,4,3,4,3,5,4,5,6,4,3]) | |
75 | + assert test_MM.getMostLikely() == 4 | |
76 | + test_MM.path([5,6,7,6,7,6,7,5,6]) | |
77 | + assert test_MM.getMostLikely() == 7 | |
78 | + test_MM.path([4,4,4,4,4,4,4]) | |
79 | + assert test_MM.getMostLikely() == 4 | |
44 | 80 | \ No newline at end of file | ... | ... |