forked from Ada-C16/adagrams-py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_wave_04.py
87 lines (65 loc) · 2.02 KB
/
test_wave_04.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
import pytest
from adagrams.game import score_word, get_highest_word_score
def test_get_highest_word_score_accurate():
# Arrange
words = ["X", "XX", "XXX", "XXXX"]
# Act
best_word = get_highest_word_score(words)
# NOTE: best_word can be a tuple or a list
# Assert
assert best_word[0] == "XXXX"
assert best_word[1] == 32
def test_get_highest_word_score_accurate_unsorted_list():
# Arrange
words = ["XXX", "XXXX", "XX", "X"]
# Act
best_word = get_highest_word_score(words)
# Assert
assert best_word[0] == "XXXX"
assert best_word[1] == 32
def test_get_highest_word_tie_prefers_shorter_word():
# Arrange
words = ["MMMM", "WWW"]
# Act
best_word = get_highest_word_score(words)
# Assert
assert score_word(words[0]) == 12
assert score_word(words[1]) == 12
assert best_word[0] == "WWW"
assert best_word[1] == 12
def test_get_highest_word_tie_prefers_shorter_word_unsorted_list():
# Arrange
words = ["WWW", "MMMM"]
# Act
best_word = get_highest_word_score(words)
# Assert
assert score_word(words[0]) == 12
assert score_word(words[1]) == 12
assert best_word[0] == "WWW"
assert best_word[1] == 12
def test_get_highest_word_tie_prefers_ten_letters():
# Arrange
words = ["AAAAAAAAAA", "BBBBBB"]
# Act
best_word = get_highest_word_score(words)
# Assert
assert best_word[0] == "AAAAAAAAAA"
assert best_word[1] == 18
def test_get_highest_word_tie_prefers_ten_letters_unsorted_list():
# Arrange
words = ["BBBBBB", "AAAAAAAAAA"]
# Act
best_word = get_highest_word_score(words)
# Assert
assert best_word[0] == "AAAAAAAAAA"
assert best_word[1] == 18
def test_get_highest_word_tie_same_length_prefers_first():
# Arrange
words = ["AAAAAAAAAA", "EEEEEEEEEE"]
# Act
best_word = get_highest_word_score(words)
# Assert
assert score_word(words[0]) == 18
assert score_word(words[1]) == 18
assert best_word[0] == words[0]
assert best_word[1] == 18