处理数组结构体
This commit is contained in:
+5
-4
@@ -463,10 +463,10 @@ func TestAttactToStruct_ErrorScenarios(t *testing.T) {
|
||||
expectedErr: "需要是非空指针",
|
||||
},
|
||||
{
|
||||
name: "不支持的类型",
|
||||
name: "自定义类型",
|
||||
structPtr: &struct{ Data []string }{},
|
||||
input: map[string]string{"data": "test"},
|
||||
expectedErr: "不支持的类型",
|
||||
input: map[string]string{"Data": `["test","test2"]`},
|
||||
expectedErr: "",
|
||||
},
|
||||
{
|
||||
name: "无效的嵌套路径",
|
||||
@@ -475,7 +475,7 @@ func TestAttactToStruct_ErrorScenarios(t *testing.T) {
|
||||
"nonexistent.field": "value",
|
||||
"basic.name": "test",
|
||||
},
|
||||
expectedErr: "", // 应该忽略不存在的字段而不报错
|
||||
expectedErr: "字段 nonexistent.field 不存在", // 应该忽略不存在的字段而不报错
|
||||
},
|
||||
}
|
||||
|
||||
@@ -592,6 +592,7 @@ func BenchmarkAttactToStruct_Nested(b *testing.B) {
|
||||
"basic.salary": "50000.0",
|
||||
"basic.is_active": "true",
|
||||
"comment": "test",
|
||||
"amount": "500.0",
|
||||
}
|
||||
|
||||
b.ResetTimer()
|
||||
|
||||
Reference in New Issue
Block a user