MCPcopy Create free account
hub / github.com/cogentcore/core / TestNodeRootJSON

Function TestNodeRootJSON

tree/io_test.go:51–70  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

49}
50
51func TestNodeRootJSON(t *testing.T) {
52 parent := testNodeTree()
53
54 var buf bytes.Buffer
55 assert.NoError(t, jsonx.Write(&parent, &buf))
56 b := buf.Bytes()
57
58 new, err := UnmarshalRootJSON(b)
59 if assert.NoError(t, err) {
60 if assert.IsType(t, &testdata.NodeEmbed{}, new) {
61 ne := new.(*testdata.NodeEmbed)
62 assert.Equal(t, parent.Mbr1, ne.Mbr1)
63 assert.Equal(t, parent.Mbr2, ne.Mbr2)
64 }
65 var buf2 bytes.Buffer
66 assert.NoError(t, jsonx.Write(new, &buf2))
67 tstb := buf2.Bytes()
68 assert.Equal(t, string(b), string(tstb))
69 }
70}
71
72func BenchmarkNodeMarshalJSON(b *testing.B) {
73 parent := testNodeTree()

Callers

nothing calls this directly

Calls 5

WriteFunction · 0.92
testNodeTreeFunction · 0.85
UnmarshalRootJSONFunction · 0.85
EqualMethod · 0.80
BytesMethod · 0.45

Tested by

no test coverage detected