-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
executable file
·51 lines (36 loc) · 1.18 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
import pytest
from ctrie import cTrie
from py_trie import PyTrie
constructors = [cTrie, PyTrie]
@pytest.mark.parametrize("constructor", constructors)
def test_find_added(constructor):
tr = constructor()
tr.add("bob")
assert tr.find("bob") == 1
@pytest.mark.parametrize("constructor", constructors)
def test_find_incomplete(constructor):
tr = constructor()
tr.add("boban")
assert tr.find("bob") == 0
@pytest.mark.parametrize("constructor", constructors)
def test_find_missing_missing_letter_before(constructor):
tr = constructor()
tr.add("bob")
assert tr.find("alice") == 0
@pytest.mark.parametrize("constructor", constructors)
def test_find_missing_letters_exist_after(constructor):
tr = constructor()
tr.add("bob")
assert tr.find("zlice") == 0
@pytest.mark.parametrize("constructor", constructors)
def test_find_missing_before_add(constructor):
tr = constructor()
assert tr.find("me") == 0
@pytest.mark.parametrize("constructor", constructors)
def test_add_many_find_missing(constructor):
tr = constructor()
tr.add("bob")
tr.add("boban")
assert tr.find("me") == 0
tr.add("alice")
assert tr.find("alice") == 1