-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrevision_test.go
69 lines (62 loc) · 1.04 KB
/
revision_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
// SPDX-FileCopyrightText: 2020 M. Shulhan <[email protected]>
// SPDX-License-Identifier: GPL-3.0-or-later
package asciidoctor
import (
"testing"
"git.sr.ht/~shulhan/pakakeh.go/lib/test"
)
func TestParseRevision(t *testing.T) {
type testCase struct {
raw string
exp Revision
}
var cases = []testCase{{
raw: `v1`,
exp: Revision{
Number: `1`,
},
}, {
raw: `15 Nov, 2020`,
exp: Revision{
Date: `15 Nov, 2020`,
},
}, {
raw: `:remark`,
exp: Revision{
Remark: `remark`,
},
}, {
raw: `v1, 15 Nov, 2020`,
exp: Revision{
Number: `1`,
Date: `15 Nov, 2020`,
},
}, {
raw: `v1: remark`,
exp: Revision{
Number: `1`,
Remark: `remark`,
},
}, {
raw: `15 Nov, 2020: remark`,
exp: Revision{
Date: `15 Nov, 2020`,
Remark: `remark`,
},
}, {
raw: `v1, 15 Nov: remark`,
exp: Revision{
Number: `1`,
Date: `15 Nov`,
Remark: `remark`,
},
}}
var (
c testCase
got Revision
)
for _, c = range cases {
got = parseRevision(c.raw)
test.Assert(t, `Revision`, c.exp, got)
}
}