@@ -984,7 +984,7 @@ func TestLoadNamedFieldOverwritten(t *testing.T) {
984984 })
985985
986986 t .Run ("overwritten named *struct" , func (t * testing.T ) {
987- type (
987+ type (
988988 Elem string
989989 Named struct {
990990 Elem string
@@ -1343,7 +1343,6 @@ func TestLoadWithCycleReference(t *testing.T) {
13431343 type Node struct {
13441344 Name string `json:"name"`
13451345 Children []* Node `json:"children,optional"`
1346- Parent * Node `json:"parent,optional"` // 指向父节点的指针
13471346 }
13481347
13491348 var c Node
@@ -1358,28 +1357,12 @@ children:
13581357 err := LoadFromYamlBytes (input , & c )
13591358 assert .NoError (t , err )
13601359
1361- // 手动回填父指针以构建完整的双向树
1362- var fillParent func (n * Node )
1363- fillParent = func (n * Node ) {
1364- for _ , child := range n .Children {
1365- child .Parent = n
1366- fillParent (child )
1367- }
1368- }
1369- fillParent (& c )
1370-
13711360 assert .Equal (t , "root" , c .Name )
13721361 assert .Len (t , c .Children , 2 )
13731362 assert .Equal (t , "child1" , c .Children [0 ].Name )
13741363 assert .Equal (t , "child2" , c .Children [1 ].Name )
13751364 assert .Len (t , c .Children [0 ].Children , 1 )
13761365 assert .Equal (t , "grandchild1" , c .Children [0 ].Children [0 ].Name )
1377-
1378- // 验证父指针
1379- assert .NotNil (t , c .Children [0 ].Parent )
1380- assert .Equal (t , "root" , c .Children [0 ].Parent .Name )
1381- assert .NotNil (t , c .Children [0 ].Children [0 ].Parent )
1382- assert .Equal (t , "child1" , c .Children [0 ].Children [0 ].Parent .Name )
13831366}
13841367
13851368func createTempFile (t * testing.T , ext , text string ) (string , error ) {
0 commit comments