From b880c628fc5fe9596f3a60de9f704c94639e2edb Mon Sep 17 00:00:00 2001 From: Paul Hammond Date: Sat, 14 Dec 2024 09:42:42 -0800 Subject: [PATCH] Add test for strings containing special characters The code already did the right thing but an extra test is useful. See https://github.com/paulhammond/jp/issues/4 for context. --- jp_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jp_test.go b/jp_test.go index 4f4ea7e..e3a5d0b 100644 --- a/jp_test.go +++ b/jp_test.go @@ -61,6 +61,10 @@ func TestExpand(t *testing.T) { // this checks for an edge case in strings {`{"slash\\" : "foo" }`, `{"slash\\":"foo"}`, "compact"}, {`{"" : "foo" }`, `{"":"foo"}`, "compact"}, + // check json inside string isn't expanded + {`{"foo":"{\"a\":\"b\",\"b\":{},\"c\":{\"a\":\"b\",\"b\":[1,2],\"c\":[]}}"}`, `{ + "foo": "{\"a\":\"b\",\"b\":{},\"c\":{\"a\":\"b\",\"b\":[1,2],\"c\":[]}}" +}`, "pretty"}, // check invalid spaces between elements are preserved {`{"foo":[1 2, 3]}`, `{"foo":[1 2,3]}`, "compact"}, {`{"foo":[1 true, 3]}`, `{"foo":[1 true,3]}`, "compact"},