-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolumn_format_test.go
56 lines (49 loc) · 1.05 KB
/
column_format_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: 2020 M. Shulhan <[email protected]>
// SPDX-License-Identifier: GPL-3.0-or-later
package asciidoctor
import (
"testing"
"git.sr.ht/~shulhan/pakakeh.go/lib/math/big"
"git.sr.ht/~shulhan/pakakeh.go/lib/test"
)
func TestParseColumnFormat(t *testing.T) {
type testCase struct {
expFormat *columnFormat
s string
expNCols int
}
var cases = []testCase{{
s: `3*`,
expNCols: 3,
expFormat: &columnFormat{
isDefault: true,
width: big.NewRat(1),
},
}, {
s: `3*^`,
expNCols: 3,
expFormat: &columnFormat{
alignHor: colAlignMiddle,
isDefault: true,
width: big.NewRat(1),
},
}, {
s: `3*.^`,
expNCols: 3,
expFormat: &columnFormat{
alignVer: colAlignMiddle,
isDefault: true,
width: big.NewRat(1),
},
}}
var (
c testCase
gotNCols int
gotFormat *columnFormat
)
for _, c = range cases {
gotNCols, gotFormat = parseColumnFormat(c.s)
test.Assert(t, c.s+` ncols`, c.expNCols, gotNCols)
test.Assert(t, c.s, c.expFormat, gotFormat)
}
}