MCPcopy Create free account
hub / github.com/alibaba/open-code-review / TestComputeLineDiff

Function TestComputeLineDiff

internal/suggestdiff/diff_test.go:7–113  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

5)
6
7func TestComputeLineDiff(t *testing.T) {
8 tests := []struct {
9 name string
10 old []string
11 new []string
12 wantLen int
13 wantAdds int
14 wantDels int
15 }{
16 {
17 name: "both empty",
18 old: nil,
19 new: nil,
20 wantLen: 0,
21 wantAdds: 0,
22 wantDels: 0,
23 },
24 {
25 name: "identical single line",
26 old: []string{"hello"},
27 new: []string{"hello"},
28 wantLen: 1,
29 wantAdds: 0,
30 wantDels: 0,
31 },
32 {
33 name: "add lines to empty",
34 old: []string{},
35 new: []string{"a", "b"},
36 wantLen: 2,
37 wantAdds: 2,
38 wantDels: 0,
39 },
40 {
41 name: "delete all lines",
42 old: []string{"a", "b"},
43 new: []string{},
44 wantLen: 2,
45 wantAdds: 0,
46 wantDels: 2,
47 },
48 {
49 name: "replace single line",
50 old: []string{"old"},
51 new: []string{"new"},
52 wantLen: 2,
53 wantAdds: 1,
54 wantDels: 1,
55 },
56 {
57 name: "insert in middle",
58 old: []string{"a", "c"},
59 new: []string{"a", "b", "c"},
60 wantLen: 3,
61 wantAdds: 1,
62 wantDels: 0,
63 },
64 {

Callers

nothing calls this directly

Calls 2

ComputeLineDiffFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected