1 Star 0 Fork 1

王布衣/pkg

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
reflect_test.go 1.78 KB
一键复制 编辑 原始数据 按行查看 历史
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)
}
})
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/quant1x/pkg.git
git@gitee.com:quant1x/pkg.git
quant1x
pkg
pkg
v0.5.1

搜索帮助