-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_apply.py
111 lines (72 loc) Β· 1.6 KB
/
test_apply.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
from patchdiff import apply, diff
def test_apply():
a = {
"a": [5, 7, 9, {"a", "b", "c"}],
"b": 6,
}
b = {
"a": [5, 2, 9, {"b", "c"}],
"b": 6,
"c": 7,
}
ops, rops = diff(a, b)
c = apply(a, ops)
assert c == b
d = apply(b, rops)
assert a == d
def test_apply_list():
a = [1, 5, 9, "sdfsdf", "fff"]
b = ["sdf", 5, 9, "c"]
ops, rops = diff(a, b)
c = apply(a, ops)
assert c == b
d = apply(b, rops)
assert a == d
def test_add_remove_list():
a = []
b = [1]
ops, rops = diff(a, b)
c = apply(a, ops)
assert c == b
d = apply(b, rops)
assert a == d
def test_add_remove_list_extended():
a = []
b = [1, 2, 3]
ops, rops = diff(a, b)
c = apply(a, ops)
assert c == b
d = apply(b, rops)
assert a == d
def test_insertion_in_list_front():
a = [1, 2]
b = [3, 1, 2]
ops, rops = diff(a, b)
c = apply(a, ops)
assert c == b
d = apply(b, rops)
assert a == d
def test_add_remove_list_extended_inverse():
a = [1, 2, 3]
b = []
ops, rops = diff(a, b)
c = apply(a, ops)
assert c == b
d = apply(b, rops)
assert a == d
def test_add_remove_list_extended_inverse_leaving_start():
a = [1, 2, 3, 4]
b = [1]
ops, rops = diff(a, b)
c = apply(a, ops)
assert c == b
d = apply(b, rops)
assert a == d
def test_add_remove_list_extended_inverse_leaving_end():
a = [1, 2, 3, 4]
b = [4]
ops, rops = diff(a, b)
c = apply(a, ops)
assert c == b
d = apply(b, rops)
assert a == d