MCPcopy Create free account
hub / github.com/davecheney/pub / TestToJSONReturnsAnEmptyArrayForKeyWithNilSlice

Function TestToJSONReturnsAnEmptyArrayForKeyWithNilSlice

internal/to/json_test.go:44–54  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

42}
43
44func TestToJSONReturnsAnEmptyArrayForKeyWithNilSlice(t *testing.T) {
45 require := require.New(t)
46
47 m := map[string]interface{}{
48 "foo": []string(nil),
49 }
50 var out mockResponseWriter
51 err := to.JSON(&out, m)
52 require.NoError(err)
53 require.Equal("{\n \"foo\": []\n}", out.String())
54}
55
56func TestTOJSONDoesNotEscapeHTML(t *testing.T) {
57 require := require.New(t)

Callers

nothing calls this directly

Calls 2

JSONFunction · 0.92
StringMethod · 0.80

Tested by

no test coverage detected