1 // Copyright (C) The Lightning Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
14 func Test(t *testing.T) { check.TestingT(t) }
16 type diffSuite struct{}
18 var _ = check.Suite(&diffSuite{})
20 func (s *diffSuite) TestDiff(c *check.C) {
21 for _, trial := range []struct {
29 expect: []string{"5A>C"},
34 expect: []string{"6del"},
39 expect: []string{"6_7del"},
44 expect: []string{"5del"},
49 expect: []string{"2_3insC"},
54 expect: []string{"3_5delinsCCC"},
59 expect: []string{"2_3insCCC"},
64 expect: []string{"3G>C", "4G>C", "7_8del", "12_13insC"},
67 // without cleanup, diffmatchpatch solves this as {"3del", "=A", "4_5insA"}
70 expect: []string{"3G>A"},
73 // without cleanup, diffmatchpatch solves this as {"3_4del", "=A", "5_6insAA"}
76 expect: []string{"3G>A", "4G>A"},
79 // without cleanup, diffmatchpatch solves this as {"3_4del", "=A", "5_6insCA"}
82 expect: []string{"3G>A", "4G>C"},
85 // without cleanup, diffmatchpatch solves this as {"3_7del", "=A", "8_9insAAACA"}
88 expect: []string{"3_7delinsAAAAC"},
91 // without cleanup, diffmatchpatch solves this as {"3_7del", "=AAAA", "11_12insCAAAA"}
92 a: "aggggggaaaaggggg",
93 b: "agAAAACaaaaggggg",
94 expect: []string{"3_7delinsAAAAC"},
99 expect: []string{"3G>C", "4G>A"},
104 expect: []string{"3G>A", "4G>A"},
109 expect: []string{"3_5delinsAAA"},
114 expect: []string{"3G>T"},
119 expect: []string{"4G>A"},
124 expect: []string{"4G>A", "6T>C"},
129 expect: []string{"4G>A", "6T>C", "9A>T"},
134 expect: []string{"4G>A", "6delinsCC", "9A>T"},
139 expect: []string{"4T>C", "6del"},
144 expect: []string{"3A>G", "4T>C"},
149 expect: []string{"3A>G", "4T>C", "7del"},
152 // should delete leftmost
153 a: "acgacaTTtttacac",
155 expect: []string{"7_8del"},
158 // should delete leftmost
159 a: "acgacATatatacac",
161 expect: []string{"6_7del"},
164 // should insert leftmost
166 b: "acgacaTTtttacac",
167 expect: []string{"6_7insTT"},
170 // should insert leftmost
172 b: "acgacATatatacac",
173 expect: []string{"5_6insAT"},
178 expect: []string{"6_9del"},
183 expect: []string{"3_6del"},
188 expect: []string{"3_4delinsG"},
193 expect: []string{"2_3insGT"},
196 a: "aGACGGACAGGGCCCgg",
198 expect: []string{"3_15del"},
203 expect: []string{"4G>A"},
208 expect: []string{"5T>C"},
211 a: "atatataTAcgcgaa",
212 b: "atatataCGcgcgaa",
213 expect: []string{"8T>C", "9A>G"},
218 expect: []string{"1_2insTAA"},
223 expect: []string{"1_2insTTCG"},
228 diffs, _ := Diff(strings.ToUpper(trial.a), strings.ToUpper(trial.b), 0)
229 for _, v := range diffs {
230 vars = append(vars, v.String())
232 c.Check(vars, check.DeepEquals, trial.expect)