Total Complexity | 4 |
Total Lines | 30 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | """This module is for testing Levenshtein distance.""" |
||
11 | class TestLevenShtein(TestCase): |
||
12 | """Test for the levenshtein module using unittest.""" |
||
13 | |||
14 | def test_same_word_should_zero(self): |
||
15 | """We use the same word there should be no difference required.""" |
||
16 | diff = LEVENSHTEIN.levenshtein("hello", "hello") |
||
17 | |||
18 | self.assertEqual(diff, 0) |
||
19 | |||
20 | def test_zero_words_should_zero(self): |
||
21 | """Special case with same word but both are empty.""" |
||
22 | diff = LEVENSHTEIN.levenshtein("", "") |
||
23 | |||
24 | self.assertEqual(diff, 0) |
||
25 | |||
26 | def test_first_longer_equal_one(self): |
||
27 | """Same word base but missing characters.""" |
||
28 | diff = LEVENSHTEIN.levenshtein("hello", "hell") |
||
29 | |||
30 | self.assertEqual(diff, 1) |
||
31 | |||
32 | def test_second_longer_equal_one(self): |
||
33 | """ |
||
34 | Reversed case of the missing character. |
||
35 | |||
36 | Method should work in both ways and not return a negative difference. |
||
37 | """ |
||
38 | diff = LEVENSHTEIN.levenshtein("hell", "hello") |
||
39 | |||
40 | self.assertEqual(diff, 1) |
||
41 |