-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsection_counters_test.go
77 lines (69 loc) · 1.3 KB
/
section_counters_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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// SPDX-FileCopyrightText: 2020 M. Shulhan <ms@kilabit.info>
// SPDX-License-Identifier: GPL-3.0-or-later
package asciidoctor
import (
"testing"
"git.sr.ht/~shulhan/pakakeh.go/lib/test"
)
func TestSectionCounters(t *testing.T) {
type testCase struct {
exp *sectionCounters
expString string
level int
}
var cases = []testCase{{
level: 2,
exp: §ionCounters{
nums: [6]byte{0, 1, 0, 0, 0, 0},
curr: 1,
},
expString: `1. `,
}, {
level: 1,
exp: §ionCounters{
nums: [6]byte{0, 2, 0, 0, 0, 0},
curr: 1,
},
expString: `2. `,
}, {
level: 2,
exp: §ionCounters{
nums: [6]byte{0, 2, 1, 0, 0, 0},
curr: 2,
},
expString: `2.1. `,
}, {
level: 3,
exp: §ionCounters{
nums: [6]byte{0, 2, 1, 1, 0, 0},
curr: 3,
},
expString: `2.1.1. `,
}, {
level: 2,
exp: §ionCounters{
nums: [6]byte{0, 2, 2, 0, 0, 0},
curr: 2,
},
expString: `2.2. `,
}, {
level: 1,
exp: §ionCounters{
nums: [6]byte{0, 3, 0, 0, 0, 0},
curr: 1,
},
expString: `3. `,
}}
var (
sec = §ionCounters{}
got *sectionCounters
gotString string
c testCase
)
for _, c = range cases {
got = sec.set(c.level)
gotString = got.String()
test.Assert(t, `set`, c.exp, got)
test.Assert(t, `String`, c.expString, gotString)
}
}