cloudflare/pint

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.75.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

internal/output/ranges_test.go

44lines · modecode

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