MCPcopy Create free account
hub / github.com/chain/Core / TestWriteArray

Function TestWriteArray

net/http/httpjson/io_test.go:15–33  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestWriteArray(t *testing.T) {
16 examples := []struct {
17 in []int
18 want string
19 }{
20 {nil, "[]"},
21 {[]int{}, "[]"},
22 {make([]int, 0), "[]"},
23 }
24
25 for _, ex := range examples {
26 rec := httptest.NewRecorder()
27 Write(context.Background(), rec, 200, ex.in)
28 got := strings.TrimSpace(rec.Body.String())
29 if got != ex.want {
30 t.Errorf("Write(%v) = %v want %v", ex.in, got, ex.want)
31 }
32 }
33}
34
35func TestWriteErr(t *testing.T) {
36 var buf bytes.Buffer

Callers

nothing calls this directly

Calls 2

WriteFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected