<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/json/write_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'json/write_test.go')
-rw-r--r--json/write_test.go57
1 files changed, 57 insertions, 0 deletions
diff --git a/json/write_test.go b/json/write_test.go
index 05b228e..b495d94 100644
--- a/json/write_test.go
+++ b/json/write_test.go
@@ -222,6 +222,63 @@ 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"],[]]]`,
+ },
+ {
+ values: []walk.Value {
+ walk.ArrayValue {{
+ Index: 0,
+ Value: walk.MapValue {{
+ Key: "a",
+ Value: walk.StringValue("a"),
+ }},
+ }},
+ walk.ArrayValue {{
+ Index: 0,
+ Value: walk.MapValue{},
+ }},
+ },
+ expected: `[{"a":"a"}]`,
+ },
}
for i, test := range tests {