代码拉取完成,页面将自动刷新
package common
import (
"testing"
)
func Test_openFile(t *testing.T) {
type args struct {
path string
}
tests := []struct {
name string
args args
wantData []byte
wantErr bool
}{
{
"invalid path", args{path: "./testdata"}, []byte{}, true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := openFile(tt.args.path)
if (err != nil) != tt.wantErr {
t.Errorf("openFile() error = %v, wantErr %v", err, tt.wantErr)
return
}
})
}
}
func Test_parse(t *testing.T) {
type args struct {
path string
}
tests := []struct {
name string
args args
want *sections
wantErr bool
}{
{"valid ini", args{path: "./testdata_valid.ini"}, nil, false},
{"invalid ini", args{"./testdata_invalid.ini"}, nil, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := parse(tt.args.path)
if (err != nil) != tt.wantErr {
t.Errorf("parse() error = %v, wantErr %v", err, tt.wantErr)
return
}
if err == nil {
if got.section("default").key("key1").string() == "" {
t.Errorf("parse() error:not get default.key1 value")
}
if _, e := got.section("custom").key("customKey2").bool(); e != nil {
t.Errorf("parse() error:not get custom.customKey2 value")
}
}
})
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。