diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2022-06-04 16:45:33 -0400 |
|---|---|---|
| committer | Dave Henderson <dhenderson@gmail.com> | 2022-06-04 16:45:33 -0400 |
| commit | e013504cbfd5150556f6f2266574e10cc6a28d2f (patch) | |
| tree | 92295f44ff31f4cce8d819f136a051bb92185850 /data | |
| parent | c66bbf16ec9ccd4348f0579c5d242c7efc96d513 (diff) | |
Support escaped slashes in JSON and YAML
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'data')
| -rw-r--r-- | data/data_test.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/data/data_test.go b/data/data_test.go index 9c67ccab..07593ea4 100644 --- a/data/data_test.go +++ b/data/data_test.go @@ -17,22 +17,26 @@ import ( func TestUnmarshalObj(t *testing.T) { expected := map[string]interface{}{ - "foo": map[string]interface{}{"bar": "baz"}, - "one": 1.0, - "true": true, + "foo": map[string]interface{}{"bar": "baz"}, + "one": 1.0, + "true": true, + "escaped": "\"/\\\b\f\n\r\t∞", } test := func(actual map[string]interface{}, err error) { + t.Helper() assert.NoError(t, err) assert.Equal(t, expected["foo"], actual["foo"], "foo") assert.Equal(t, expected["one"], actual["one"], "one") assert.Equal(t, expected["true"], actual["true"], "true") + assert.Equal(t, expected["escaped"], actual["escaped"], "escaped") } - test(JSON(`{"foo":{"bar":"baz"},"one":1.0,"true":true}`)) + test(JSON(`{"foo":{"bar":"baz"},"one":1.0,"true":true,"escaped":"\"\/\\\b\f\n\r\t\u221e"}`)) test(YAML(`foo: bar: baz one: 1.0 'true': true +escaped: "\"\/\\\b\f\n\r\t\u221e" `)) test(YAML(`anchor: &anchor bar: baz @@ -40,6 +44,7 @@ foo: <<: *anchor one: 1.0 'true': true +escaped: "\"\/\\\b\f\n\r\t\u221e" `)) test(YAML(`# this comment marks an empty (nil!) document --- @@ -49,6 +54,7 @@ foo: bar: baz one: 1.0 'true': true +escaped: "\"\/\\\b\f\n\r\t\u221e" `)) obj := make(map[string]interface{}) |
