-
Notifications
You must be signed in to change notification settings - Fork 0
/
line_range_test.go
56 lines (49 loc) · 918 Bytes
/
line_range_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// SPDX-FileCopyrightText: 2023 M. Shulhan <[email protected]>
// SPDX-License-Identifier: GPL-3.0-or-later
//go:build !integration
package awwan
import (
"testing"
"git.sr.ht/~shulhan/pakakeh.go/lib/test"
)
func TestParseLineRange(t *testing.T) {
type testCase struct {
raw string
exp lineRange
}
var cases = []testCase{{
raw: ``,
}, {
raw: ` 1`,
exp: lineRange{
list: []linePosition{
{start: 1, end: 1},
},
},
}, {
raw: ` ,1,`,
exp: lineRange{
list: []linePosition{
{start: 1, end: 1},
},
},
}, {
raw: ` ,1,2-1,,-4,-4-6,4-6-,8-10,8-12,10-12,10-,16-,18-20`,
exp: lineRange{
list: []linePosition{
{start: 1, end: 1},
{start: 8, end: 10},
{start: 16, end: 0},
},
},
}}
var (
c testCase
got lineRange
)
for _, c = range cases {
got = parseLineRange(c.raw)
t.Logf("got.list: %+v", got.list)
test.Assert(t, c.raw, c.exp, got)
}
}