Skip to content

Commit

Permalink
Add test for strings containing special characters
Browse files Browse the repository at this point in the history
The code already did the right thing but an extra test is useful. See
#4 for context.
  • Loading branch information
paulhammond committed Dec 14, 2024
1 parent a9d7eaa commit b880c62
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions jp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down

0 comments on commit b880c62

Please sign in to comment.