MCPcopy Create free account
hub / github.com/kubernetes/test-infra / TestDiffProfilesBasicDiff

Function TestDiffProfilesBasicDiff

gopherage/pkg/cov/diff_test.go:26–67  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func TestDiffProfilesBasicDiff(t *testing.T) {
27 a := []*cover.Profile{
28 {
29 FileName: "a.go",
30 Mode: "count",
31 Blocks: []cover.ProfileBlock{
32 {StartLine: 1, StartCol: 14, EndLine: 5, EndCol: 13, NumStmt: 4, Count: 3},
33 {StartLine: 7, StartCol: 4, EndLine: 12, EndCol: 4, NumStmt: 3, Count: 2},
34 },
35 },
36 }
37 b := []*cover.Profile{
38 {
39 FileName: "a.go",
40 Mode: "count",
41 Blocks: []cover.ProfileBlock{
42 {StartLine: 1, StartCol: 14, EndLine: 5, EndCol: 13, NumStmt: 4, Count: 7},
43 {StartLine: 7, StartCol: 4, EndLine: 12, EndCol: 4, NumStmt: 3, Count: 2},
44 },
45 },
46 }
47
48 result, err := cov.DiffProfiles(a, b)
49 if err != nil {
50 t.Fatalf("DiffProfiles failed: %v", err)
51 }
52
53 expected := []*cover.Profile{
54 {
55 FileName: "a.go",
56 Mode: "count",
57 Blocks: []cover.ProfileBlock{
58 {StartLine: 1, StartCol: 14, EndLine: 5, EndCol: 13, NumStmt: 4, Count: 4},
59 {StartLine: 7, StartCol: 4, EndLine: 12, EndCol: 4, NumStmt: 3, Count: 0},
60 },
61 },
62 }
63
64 if !reflect.DeepEqual(result, expected) {
65 t.Fatal("diffed profile incorrect")
66 }
67}
68
69func TestDiffProfilesWrongFileName(t *testing.T) {
70 a := []*cover.Profile{

Callers

nothing calls this directly

Calls 1

DiffProfilesFunction · 0.92

Tested by

no test coverage detected