Passed
Push — master ( 39de41...cc7e60 )
by Xianshun
01:46
created

KnuthMorrisPrattUnitTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 7
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A test_search() 0 5 1
1
import unittest
2
3
from pyalgs.algorithms.strings.substring_search import BruteForceSubstringSearch, RabinKarp, BoyerMoore, \
4
    KnuthMorrisPratt
5
from tests.algorithms.strings.util import some_text
6
7
8
class BruteForceSubstringSearchUnitTest(unittest.TestCase):
9
10
    def test_search(self):
11
        t = some_text()
12
        ss = BruteForceSubstringSearch('men')
13
        self.assertNotEqual(-1, ss.search_in(t))
14
        self.assertEqual(-1, ss.search_in('Hello World'))
15
16
17
class RabinKarpUnitTest(unittest.TestCase):
18
19
    def test_search(self):
20
        t = some_text()
21
        ss = RabinKarp('men')
22
        self.assertNotEqual(-1, ss.search_in(t))
23
        self.assertEqual(-1, ss.search_in('Hello World'))
24
25
26
class BoyerMooreUnitTest(unittest.TestCase):
27
28
    def test_search(self):
29
        t = some_text()
30
        ss = BoyerMoore('men')
31
        self.assertNotEqual(-1, ss.search_in(t))
32
        self.assertEqual(-1, ss.search_in('Hello World'))
33
34
35
class KnuthMorrisPrattUnitTest(unittest.TestCase):
36
37
    def test_search(self):
38
        t = some_text()
39
        ss = KnuthMorrisPratt('men')
40
        self.assertNotEqual(-1, ss.search_in(t))
41
        self.assertEqual(-1, ss.search_in('Hello World'))
42
43
if __name__ == '__main__':
44
    unittest.main()