-
Notifications
You must be signed in to change notification settings - Fork 0
/
element_attribute_test.go
80 lines (73 loc) · 1.44 KB
/
element_attribute_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
78
79
80
// 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 Test_parseElementAttribute(t *testing.T) {
type testCase struct {
raw string
exp elementAttribute
}
var cases = []testCase{{
raw: ``,
}, {
raw: `[]`,
}, {
raw: `[STYLE]`,
exp: elementAttribute{
rawStyle: `STYLE`,
},
}, {
raw: `[style#id]`,
exp: elementAttribute{
ID: `id`,
rawStyle: `style`,
},
}, {
raw: `[#id.role1.role2,options="opt1,opt2"]`,
exp: elementAttribute{
ID: `id`,
roles: []string{`role1`, `role2`},
options: []string{`opt1`, `opt2`},
pos: 1,
},
}, {
raw: `[cols="3*,^"]`,
exp: elementAttribute{
Attrs: map[string]string{
attrNameCols: `3*,^`,
},
},
}, {
raw: `[quote, attribution]`,
exp: elementAttribute{
Attrs: map[string]string{
attrNameAttribution: `attribution`,
},
rawStyle: `quote`,
style: styleQuote,
pos: 1,
},
}, {
raw: `[quote, attribution, citation]`,
exp: elementAttribute{
Attrs: map[string]string{
attrNameAttribution: `attribution`,
attrNameCitation: `citation`,
},
rawStyle: `quote`,
style: styleQuote,
pos: 2,
},
}}
var (
c testCase
)
for _, c = range cases {
var got = elementAttribute{}
got.parseElementAttribute([]byte(c.raw))
test.Assert(t, c.raw, c.exp, got)
}
}