-
Notifications
You must be signed in to change notification settings - Fork 1
/
table_helper_test.go
51 lines (43 loc) · 936 Bytes
/
table_helper_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
package styledconsole
import (
"testing"
"github.com/stretchr/testify/assert"
)
// TestGetSubstring checks that column widths are correct
func TestGetColumnWidths(t *testing.T) {
assert := assert.New(t)
assert.Equal(
[]int{7, 7, 5},
getColumnWidths(
[]string{"one", "two", "three"},
[][]string{{"1", "big two", "3"}, {"big one", "2", "3"}},
),
)
// with UTF8
assert.Equal(
[]int{7, 7, 5},
getColumnWidths(
[]string{"un", "deux", "troïs"},
[][]string{{"1", "big twô", "3"}, {"big @ne", "2", "3"}},
),
)
}
// TestFormatOneRow checks rows are well formatted
func TestFormatOneRow(t *testing.T) {
assert := assert.New(t)
assert.Equal(
"| one | two | three |",
formatOneRow(
[]string{"one", "two", "three"},
[]int{7, 7, 5},
),
)
// with UTF8
assert.Equal(
"| un | deux | troïs |",
formatOneRow(
[]string{"un", "deux", "troïs"},
[]int{7, 7, 5},
),
)
}