-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontent_test.go
105 lines (85 loc) · 2.96 KB
/
content_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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// -*- coding: utf-8 -*-
// content_test.go
// -----------------------------------------------------------------------------
//
// Started on <sáb 19-12-2020 22:45:26.735542876 (1608414326)>
// Carlos Linares López <[email protected]>
//
package table
import (
"reflect"
"testing"
)
func Test_content_Process(t *testing.T) {
type args struct {
colspec string
text string
}
tests := []struct {
name string
args args
want []formatter
}{
// All tests are performed over a table which consists of only one row
// and one column.
{args: args{colspec: "|l",
text: ""},
want: []formatter{content("")}},
{args: args{colspec: "|c",
text: ""},
want: []formatter{content("")}},
{args: args{colspec: "|r",
text: ""},
want: []formatter{content("")}},
{args: args{colspec: "|l",
text: "Black lives matter"},
want: []formatter{content("Black lives matter")}},
{args: args{colspec: "|c",
text: "Black lives matter"},
want: []formatter{content("Black lives matter")}},
{args: args{colspec: "|r",
text: "Black lives matter"},
want: []formatter{content("Black lives matter")}},
{args: args{colspec: "|l",
text: "Black\nlives\nmatter"},
want: []formatter{content("Black"), content("lives"), content("matter")}},
{args: args{colspec: "|c",
text: "Black\nlives\nmatter"},
want: []formatter{content("Black"), content("lives"), content("matter")}},
{args: args{colspec: "|r",
text: "Black\nlives\nmatter"},
want: []formatter{content("Black"), content("lives"), content("matter")}},
{args: args{colspec: "|l",
text: "Black\nlives\nmatter\n"},
want: []formatter{content("Black"), content("lives"), content("matter"), content("")}},
{args: args{colspec: "|c",
text: "Black\nlives\nmatter\n"},
want: []formatter{content("Black"), content("lives"), content("matter"), content("")}},
{args: args{colspec: "|r",
text: "Black\nlives\nmatter\n"},
want: []formatter{content("Black"), content("lives"), content("matter"), content("")}},
{args: args{colspec: "|l",
text: "Black\n\nlives\nmatter"},
want: []formatter{content("Black"), content(""), content("lives"), content("matter")}},
{args: args{colspec: "|c",
text: "Black\nlives\n\nmatter"},
want: []formatter{content("Black"), content("lives"), content(""), content("matter")}},
{args: args{colspec: "|r",
text: "Black\nlives\nmatter\n\nAlways"},
want: []formatter{content("Black"), content("lives"), content("matter"), content(""), content("Always")}},
}
for _, tt := range tests {
// Create a table with the given column specification, and add the given
// text in a single row
if tab, ok := NewTable(tt.args.colspec); ok != nil {
panic("It was not possible to create a table!")
} else {
tab.AddRow(tt.args.text)
t.Run(tt.name, func(t *testing.T) {
if got := tab.cells[0][0].Process(tab, 0, 0); !reflect.DeepEqual(got, tt.want) {
t.Errorf("content.Process() = '%v', want '%v'", got, tt.want)
}
})
}
}
}