This repository was archived by the owner on Feb 3, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathstyles_test.v
More file actions
73 lines (69 loc) · 1.36 KB
/
Copy pathstyles_test.v
File metadata and controls
73 lines (69 loc) · 1.36 KB
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
module termtable
import os
fn test_table_styles() {
custom_style := StyleConfig{
headerline: Sepline{
left: ''
right: ''
cross: ''
sep: '='
}
colsep: ' '
}
mut table := Table{
data: [
['Name', 'Age', 'Sex'],
['Max', '13', 'male'],
['Moritz', '12', 'male'],
['Lisa', '42', 'female'],
]
header_style: .plain
}
for i := 0; true; i++ {
s := unsafe { Style(i) }
if s.str() == 'unknown enum value' {
break
}
table.style = s
if s == .custom {
table.custom_style = custom_style
}
mut exp := os.read_file('${dir}/tests/styles/${s.str()}.out') or { panic(err) }
exp = exp.trim_string_right('\n')
assert table.str() == exp
}
}
fn test_single_row_tables() {
table := Table{
data: [
['Foo', 'bar', 'baz'],
]
header_style: .plain
style: .grid
}
mut exp := os.read_file('${dir}/tests/grid_single_row.out') or { panic(err) }
exp = exp.trim_string_right('\n')
assert table.str() == exp
}
fn test_no_padding() {
mut table := Table{
data: [
['Name', 'Age', 'Sex'],
['Max', '13', 'male'],
['Lisa', '42', 'female'],
]
padding: 0
header_style: .plain
}
mut styles := []Style{}
styles = [
.plain,
.simple,
]
for s in styles {
table.style = s
mut exp := os.read_file('${dir}/tests/no_padding/${s.str()}.out') or { panic(err) }
exp = exp.trim_string_right('\n')
assert table.str() == exp
}
}