summaryrefslogtreecommitdiff
path: root/test_wordle.py
blob: 9ce5f2ced56fbf99fc1c2171dfd43332d9ba1da9 (plain)
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
import unittest
import wordle


class TestWordle(unittest.TestCase):
    def test_exact_match(self):
        answer = 'aaaaa'
        guess = 'aaaaa'

        expected_score = [wordle.full_match_character for i in range(
            len(answer))]

        actual_score = wordle.compare_guess_to_answer(guess, answer)
        self.assertEqual(actual_score, expected_score)

    def test_no_letters_match(self):
        answer = 'aaaaa'
        guess = 'bbbbb'

        expected_score = [wordle.no_match_character for i in range(
            len(answer))]

        actual_score = wordle.compare_guess_to_answer(guess, answer)
        self.assertEqual(actual_score, expected_score)

    def test_only_one_letter_full_match(self):
        answer = 'aaaaa'
        guess = 'abbbb'

        expected_score = [
                wordle.full_match_character,
                wordle.no_match_character,
                wordle.no_match_character,
                wordle.no_match_character,
                wordle.no_match_character
        ]

        actual_score = wordle.compare_guess_to_answer(guess, answer)
        self.assertEqual(actual_score, expected_score)

    def test_only_one_letter_partial_match(self):
        answer = 'abaaa'
        guess = 'bcccc'

        expected_score = [
                wordle.partial_match_character,
                wordle.no_match_character,
                wordle.no_match_character,
                wordle.no_match_character,
                wordle.no_match_character
        ]

        actual_score = wordle.compare_guess_to_answer(guess, answer)
        self.assertEqual(actual_score, expected_score)

    def test_multiple_letters_partial_match(self):
        answer = 'ababa'
        guess = 'bcbcc'

        expected_score = [
                wordle.partial_match_character,
                wordle.no_match_character,
                wordle.partial_match_character,
                wordle.no_match_character,
                wordle.no_match_character
        ]

        actual_score = wordle.compare_guess_to_answer(guess, answer)
        self.assertEqual(actual_score, expected_score)

    def test_multiple_letters_in_guess_match_one_letter_in_answer(self):
        answer = 'aab'
        guess = 'bbc'

        expected_score = [
                wordle.partial_match_character,
                wordle.no_match_character,
                wordle.no_match_character,
                # wordle.no_match_character,
                # wordle.no_match_character
        ]

        actual_score = wordle.compare_guess_to_answer(guess, answer)
        self.assertEqual(actual_score, expected_score)


if __name__ == '__main__':
    unittest.main()