File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -164,6 +164,20 @@ func TestCircularData(t *testing.T) {
164164 circSlice := make ([]any , 1 )
165165 circSlice [0 ] = circSlice
166166
167+ // Test for indirect circular reference bug with maps
168+ // Map A -> Slice B -> Map A (should detect circular reference)
169+ circMap := make (map [string ]any )
170+ indirectSlice := make ([]any , 1 )
171+ circMap ["slice" ] = indirectSlice
172+ indirectSlice [0 ] = circMap
173+
174+ // Test for indirect circular reference bug with nested maps
175+ // Map A -> Map B -> Map A (should detect circular reference)
176+ mapA := make (map [string ]any )
177+ mapB := make (map [string ]any )
178+ mapA ["b" ] = mapB
179+ mapB ["a" ] = mapA
180+
167181 tests := []struct {
168182 name string
169183 value any
@@ -184,6 +198,16 @@ func TestCircularData(t *testing.T) {
184198 value : circSlice ,
185199 want : `[CIRCULAR_REF]` ,
186200 },
201+ {
202+ name : "circMapViaSlice" ,
203+ value : circMap ,
204+ want : `{` + "`slice`" + `:[CIRCULAR_REF]}` ,
205+ },
206+ {
207+ name : "circMapViaMap" ,
208+ value : mapA ,
209+ want : `{` + "`b`" + `:{` + "`a`" + `:CIRCULAR_REF}}` ,
210+ },
187211 }
188212 for _ , tt := range tests {
189213 t .Run (tt .name , func (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments