forked from goodsign/monday
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils_layout_test.go
57 lines (52 loc) · 1.25 KB
/
utils_layout_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
package monday
import (
"reflect"
"testing"
)
type DateLayoutTest struct {
name string
input string
expected []dateStringLayoutItem
}
var dateLayoutTests = []DateLayoutTest{
{"ANSIC", "Thu Feb 4 21:00:57 2010", []dateStringLayoutItem{
{"Thu", true, false},
{" ", false, false},
{"Feb", true, false},
{" ", false, false},
{"4", false, true},
{" ", false, false},
{"21", false, true},
{":", false, false},
{"00", false, true},
{":", false, false},
{"57", false, true},
{" ", false, false},
{"2010", false, true},
}},
{"RFC1123Z", "Wed, 04 Feb 2013 21:00:57 -0800", []dateStringLayoutItem{
{"Wed", true, false},
{", ", false, false},
{"04", false, true},
{" ", false, false},
{"Feb", true, false},
{" ", false, false},
{"2013", false, true},
{" ", false, false},
{"21", false, true},
{":", false, false},
{"00", false, true},
{":", false, false},
{"57", false, true},
{" -", false, false},
{"0800", false, true},
}},
}
func TestLayoutParser(t *testing.T) {
for i, ts := range dateLayoutTests {
items := stringToLayoutItems(ts.input)
if !reflect.DeepEqual(items, ts.expected) {
t.Errorf("Test #%d (%s) failed.\n Got: %#v\n Expected: %#v\n", i, ts.name, items, ts.expected)
}
}
}