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

Function TestComputeLineDiff

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

ComputeLineDiffFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected