-
Notifications
You must be signed in to change notification settings - Fork 245
/
reflect_test.go
93 lines (91 loc) · 1.78 KB
/
reflect_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
package gocsv
import "testing"
func Test_fieldInfo_matchesKey(t *testing.T) {
type fields struct {
keys []string
omitEmpty bool
IndexChain []int
defaultValue string
partial bool
}
type args struct {
key string
}
tests := []struct {
name string
fields fields
args args
want bool
}{
{
name: "valid value",
fields: fields{
keys: []string{"date"},
},
args: args{"date"},
want: true,
},
{
name: "zero width space (U+200B)",
fields: fields{
keys: []string{"date"},
},
args: args{"\u200Bdate"},
want: true,
},
{
name: "zero width non-joiner (U+200C)",
fields: fields{
keys: []string{"date"},
},
args: args{"\u200Cdate"},
want: true,
},
{
name: "zero width joiner (U+200D)",
fields: fields{
keys: []string{"date"},
},
args: args{"\u200Ddate"},
want: true,
},
{
name: "zero width no-break space (U+FEFF)",
fields: fields{
keys: []string{"date"},
},
args: args{"\uFEFFdate"},
want: true,
},
{
name: "zero width no-break space (U+FEFF) in the middle of the string",
fields: fields{
keys: []string{"date"},
},
args: args{"da\uFEFFte"},
want: true,
},
{
name: "zero width no-break space (U+FEFF) in the end of the string",
fields: fields{
keys: []string{"date"},
},
args: args{"date\uFEFF"},
want: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
f := fieldInfo{
keys: tt.fields.keys,
omitEmpty: tt.fields.omitEmpty,
IndexChain: tt.fields.IndexChain,
defaultValue: tt.fields.defaultValue,
partial: tt.fields.partial,
}
if got := f.matchesKey(tt.args.key); got != tt.want {
t.Errorf("matchesKey() = %v, want %v", got, tt.want)
}
})
}
}