diff options
author | Charlie Stanton <charlie@shtanton.xyz> | 2024-03-25 15:36:31 +0000 |
---|---|---|
committer | Charlie Stanton <charlie@shtanton.xyz> | 2024-03-25 15:36:31 +0000 |
commit | e9a296e8bc8f25138ea5910c8b09661f8ae25f10 (patch) | |
tree | a14068e694b268872e6f605b3db0164ae875ec0e /json/write_test.go | |
parent | c6c1c67402f89c94fee040c2c740d96e61cab669 (diff) | |
download | stred-go-e9a296e8bc8f25138ea5910c8b09661f8ae25f10.tar |
Fix bug in json/write.go inMapAt and inArrayAt
Diffstat (limited to 'json/write_test.go')
-rw-r--r-- | json/write_test.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/json/write_test.go b/json/write_test.go index 05b228e..a0e8c3e 100644 --- a/json/write_test.go +++ b/json/write_test.go @@ -222,6 +222,47 @@ func TestWrite(t *testing.T) { }, expected: `[[100],[],null,[200]]`, }, + { + values: []walk.Value { + walk.MapValue {{ + Key: "a", + Value: walk.MapValue {{ + Key: "b", + Value: walk.StringValue("map"), + }}, + }}, + walk.MapValue {{ + Key: "a", + Value: walk.ArrayValue {{ + Index: 0, + Value: walk.StringValue("array"), + }}, + }}, + }, + expected: `{"a":{"b":"map"},"a":["array"]}`, + }, + { + values: []walk.Value { + walk.ArrayValue {{ + Index: 0, + Value: walk.ArrayValue {{ + Index: 0, + Value: walk.ArrayValue {{ + Index: 1, + Value: walk.StringValue("a"), + }}, + }}, + }}, + walk.ArrayValue {{ + Index: 0, + Value: walk.ArrayValue {{ + Index: 1, + Value: walk.ArrayValue{}, + }}, + }}, + }, + expected: `[[["a"],[]]]`, + }, } for i, test := range tests { |