-
Notifications
You must be signed in to change notification settings - Fork 0
/
otcatchup_test.py
56 lines (48 loc) · 2.06 KB
/
otcatchup_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
from otcatchup import isValid
# a: True
isValid_a = isValid(
'Repl.it uses operational transformations to keep everyone in a multiplayer repl in sync.',
'Repl.it uses operational transformations.',
'[{"op": "skip", "count": 40}, {"op": "delete", "count": 47}]'
)
# b: False
isValid_b = isValid(
'Repl.it uses operational transformations to keep everyone in a multiplayer repl in sync.',
'Repl.it uses operational transformations.',
'[{"op": "skip", "count": 45}, {"op": "delete", "count": 47}]'
)
# c: False
isValid_c = isValid(
'Repl.it uses operational transformations to keep everyone in a multiplayer repl in sync.',
'Repl.it uses operational transformations.',
'[{"op": "skip", "count": 40}, {"op": "delete", "count": 47}, {"op": "skip", "count": 2}]'
)
# d: True
isValid_d = isValid(
'Repl.it uses operational transformations to keep everyone in a multiplayer repl in sync.',
'We use operational transformations to keep everyone in a multiplayer repl in sync.',
'[{"op": "delete", "count": 7}, {"op": "insert", "chars": "We"}, {"op": "skip", "count": 4}, {"op": "delete", "count": 1}]'
)
# e: False
isValid_e = isValid(
'Repl.it uses operational transformations to keep everyone in a multiplayer repl in sync.',
'We can use operational transformations to keep everyone in a multiplayer repl in sync.',
'[{"op": "delete", "count": 7}, {"op": "insert", "chars": "We"}, {"op": "skip", "count": 4}, {"op": "delete", "count": 1}]'
)
# f: True
isValid_f = isValid(
'Repl.it uses operational transformations to keep everyone in a multiplayer repl in sync.',
'Repl.it uses operational transformations to keep everyone in a multiplayer repl in sync.',
'[]'
)
isValid_table = [
{'actual': isValid_a, 'expected': True},
{'actual': isValid_b, 'expected': False},
{'actual': isValid_c, 'expected': False},
{'actual': isValid_d, 'expected': True},
{'actual': isValid_e, 'expected': False},
{'actual': isValid_f, 'expected': True},
]
# assert all cases
def test_assert_isValid():
assert all(case['actual'] == case['expected'] for case in isValid_table)