MCPcopy Index your code
hub / github.com/opencontainers/runc / TestWriteJSON

Function TestWriteJSON

libcontainer/utils/utils_test.go:53–72  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

51}
52
53func TestWriteJSON(t *testing.T) {
54 person := struct {
55 Name string
56 Age int
57 }{
58 Name: "Alice",
59 Age: 30,
60 }
61
62 var b bytes.Buffer
63 err := WriteJSON(&b, person)
64 if err != nil {
65 t.Fatal(err)
66 }
67
68 expected := `{"Name":"Alice","Age":30}`
69 if b.String() != expected {
70 t.Errorf("expected to write %s but was %s", expected, b.String())
71 }
72}

Callers

nothing calls this directly

Calls 2

WriteJSONFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…