MCPcopy Create free account
hub / github.com/francoispqt/gojay / TestEncoderObjectEncodeAPI

Function TestEncoderObjectEncodeAPI

encode_object_test.go:83–100  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

81}
82
83func TestEncoderObjectEncodeAPI(t *testing.T) {
84 t.Run("encode-basic", func(t *testing.T) {
85 builder := &strings.Builder{}
86 enc := NewEncoder(builder)
87 err := enc.EncodeObject(&testObject{
88 "漢字", nil, 1, nil, 1, nil, 1, nil, 1, nil, 1, nil, 1, nil, 1, nil,
89 1, nil, 1, nil, 1.1, nil, 1.1, nil, true, nil,
90 &testObject{}, testSliceInts{}, interface{}("test"),
91 })
92 assert.Nil(t, err, "Error should be nil")
93 assert.Equal(
94 t,
95 `{"testStr":"漢字","testInt":1,"testInt64":1,"testInt32":1,"testInt16":1,"testInt8":1,"testUint64":1,"testUint32":1,"testUint16":1,"testUint8":1,"testFloat64":1.1,"testFloat32":1.1,"testBool":true}`,
96 builder.String(),
97 "Result of marshalling is different as the one expected",
98 )
99 })
100}
101
102func TestEncoderObjectMarshalAPI(t *testing.T) {
103 t.Run("marshal-basic", func(t *testing.T) {

Callers

nothing calls this directly

Calls 3

EncodeObjectMethod · 0.95
NewEncoderFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…