-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
56 lines (45 loc) · 1.64 KB
/
test.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
"""
Create a set unit test for rsplitter
"""
import unittest
import time
import rsplitter
TEXTS = [
("Thequickbrownfoxjumpsoverthelazydog", "The quick brown fox jumps over the lazy dog"),
("rustisveryfast", "rust is very fast"),
("pythonisfast", "python is fast"),
("javaisjustbad", "java is just bad"),
("cisgreat", "c is great"),
("c++isc++", "c++ is c++"),
]
class TestRsplitter(unittest.TestCase):
def test_default(self):
"""
Test the default rsplitter
"""
self.assertEqual(rsplitter.split("Thequickbrownfoxjumpsoverthelazydog"), 'The quick brown fox jumps over the lazy dog')
def test_custom_language_model(self):
"""
Test the custom language model
"""
language_model = rsplitter.LanguageModel('src/corpus.txt')
self.assertEqual(language_model.split("Thequickbrownfoxjumpsoverthelazydog"), 'The quick brown fox jumps over the lazy dog')
def test_default_execution_speed(self):
"""
Test the default execution speed
"""
start = time.perf_counter()
rsplitter.split("Thequickbrownfoxjumpsoverthelazydog")
end = time.perf_counter()
self.assertLessEqual(end - start, 0.1)
def test_custom_language_model_execution_speed(self):
"""
Test the custom language model execution speed
"""
language_model = rsplitter.LanguageModel('src/corpus.txt')
start = time.perf_counter()
language_model.split("Thequickbrownfoxjumpsoverthelazydog")
end = time.perf_counter()
self.assertLessEqual(end - start, 0.1)
if __name__ == '__main__':
unittest.main()