]> Cypherpunks repositories - gostls13.git/commitdiff
log/slog: improve test coverage of JSON handler
authorJonathan Amsterdam <jba@google.com>
Fri, 19 May 2023 11:51:36 +0000 (07:51 -0400)
committerJonathan Amsterdam <jba@google.com>
Mon, 22 May 2023 19:05:49 +0000 (19:05 +0000)
Change-Id: I31e96fc1329bb17937974ed3dbfda3448e53d37e
Reviewed-on: https://go-review.googlesource.com/c/go/+/495978
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/log/slog/json_handler_test.go

index 61078caec816391e870934b29e50b008d106d9ca..dcfd701dd403c8954a0a2276daceccdb7a7615b6 100644 (file)
@@ -76,9 +76,12 @@ func (jsonMarshalerError) Error() string { return "oops" }
 func TestAppendJSONValue(t *testing.T) {
        // jsonAppendAttrValue should always agree with json.Marshal.
        for _, value := range []any{
-               "hello",
+               "hello\r\n\t\a",
                `"[{escape}]"`,
                "<escapeHTML&>",
+               // \u2028\u2029 is an edge case in JavaScript vs JSON.
+               // \xF6 is an incomplete encoding.
+               "\u03B8\u2028\u2029\uFFFF\xF6",
                `-123`,
                int64(-9_200_123_456_789_123_456),
                uint64(9_200_123_456_789_123_456),