cloudflare/pint

Public

mirrored from https://github.com/cloudflare/pintAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.3.1

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

internal/output/ranges_test.go

46lines · modecode

1package output_test
2
3import (
4 "strconv"
5 "testing"
6
7 "github.com/cloudflare/pint/internal/output"
8 "github.com/google/go-cmp/cmp"
9)
10
11func TestFormatLineRangeString(t *testing.T) {
12 type testCaseT struct {
13 lines []int
14 output string
15 }
16
17 testCases := []testCaseT{
18 {
19 lines: []int{1, 2, 3},
20 output: "1-3",
21 },
22 {
23 lines: []int{2, 1, 3},
24 output: "1-3",
25 },
26 {
27 lines: []int{1, 3, 5},
28 output: "1 3 5",
29 },
30 {
31 lines: []int{13, 12, 3, 5, 4, 7},
32 output: "3-5 7 12-13",
33 },
34 }
35
36 for i, tc := range testCases {
37 t.Run(strconv.Itoa(i+1), func(t *testing.T) {
38 output := output.FormatLineRangeString(tc.lines)
39
40 if diff := cmp.Diff(tc.output, output); diff != "" {
41 t.Errorf("FormatLineRangeString() returned wrong output (-want +got):\n%s", diff)
42 return
43 }
44 })
45 }
46}
47