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{"3_4delinsCC", "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{"3_4delinsAA"},
79 // without cleanup, diffmatchpatch solves this as {"3_4del", "=A", "5_6insCA"}
82 expect: []string{"3_4delinsAC"},
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{"3_4delinsCA"},
104 expect: []string{"3_4delinsAA"},
109 expect: []string{"3G>T"},
114 expect: []string{"4G>A"},
119 diffs, _ := Diff(strings.ToUpper(trial.a), strings.ToUpper(trial.b), 0)
120 for _, v := range diffs {
121 vars = append(vars, v.String())
123 c.Check(vars, check.DeepEquals, trial.expect)