(t *testing.T)
| 24 | ) |
| 25 | |
| 26 | func 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 | |
| 69 | func TestDiffProfilesWrongFileName(t *testing.T) { |
| 70 | a := []*cover.Profile{ |
nothing calls this directly
no test coverage detected