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 insert leftmost
160 b: "acgacaTTtttacac",
161 expect: []string{"6_7insTT"},
166 expect: []string{"6_9del"},
171 expect: []string{"2_5del"},
176 diffs, _ := Diff(strings.ToUpper(trial.a), strings.ToUpper(trial.b), 0)
177 for _, v := range diffs {
178 vars = append(vars, v.String())
180 c.Check(vars, check.DeepEquals, trial.expect)