整合嵌套结构, 基础验证通过

This commit is contained in:
2025-03-20 18:58:53 +08:00
parent a40288f149
commit 0754f879e8
2 changed files with 16 additions and 10 deletions

View File

@ -16,11 +16,19 @@ import (
// TestRun_Simple_Data 无嵌套、无复杂数据类型的处理
func TestRun_Simple_Data(t *testing.T) {
testMap := map[string]any{
"age": 18,
userInfo := map[string]any{
"age": 1800,
"height": 179.5,
"name": "baicha",
}
companyInfo := map[string]any{
"address": "beijing",
}
testMap := map[string]any{
"user": userInfo,
"company": companyInfo,
}
sourceByteData, _ := json.Marshal(testMap)
fieldList := []StructField{
{
@ -34,15 +42,15 @@ func TestRun_Simple_Data(t *testing.T) {
},
{
Tag: "max",
Args: []string{"20"},
Args: []string{"2000"},
},
},
DefaultValue: "",
SourcePath: "age",
SourcePath: "user.age",
TargetPath: "user_age",
Errmsg: "年龄必须在[1,20]之间",
Errmsg: "年龄必须在[1,2000]之间",
},
}
_, err := Run(sourceByteData, fieldList)
fmt.Println(err)
res, err := Run(sourceByteData, fieldList)
fmt.Println(err, string(res))
}