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

Function TestEncoderInterfaceEncodeAPI

encode_interface_test.go:135–165  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

133}
134
135func TestEncoderInterfaceEncodeAPI(t *testing.T) {
136 t.Run("encode-all-types", func(t *testing.T) {
137 for _, test := range encoderTestCases {
138 builder := &strings.Builder{}
139 enc := BorrowEncoder(builder)
140 err := enc.Encode(test.v)
141 enc.Release()
142 test.expectations(t, builder.String(), err)
143 }
144 })
145 t.Run("encode-all-types-write-error", func(t *testing.T) {
146 v := ""
147 w := TestWriterError("")
148 enc := BorrowEncoder(w)
149 err := enc.Encode(v)
150 assert.NotNil(t, err, "err should not be nil")
151 })
152 t.Run("encode-all-types-pool-error", func(t *testing.T) {
153 v := ""
154 w := TestWriterError("")
155 enc := BorrowEncoder(w)
156 enc.isPooled = 1
157 defer func() {
158 err := recover()
159 assert.NotNil(t, err, "err should not be nil")
160 assert.IsType(t, InvalidUsagePooledEncoderError(""), err, "err should be of type InvalidUsagePooledEncoderError")
161 }()
162 _ = enc.Encode(v)
163 assert.True(t, false, "should not be called as decoder should have panicked")
164 })
165}
166
167func TestEncoderInterfaceMarshalAPI(t *testing.T) {
168 t.Run("marshal-all-types", func(t *testing.T) {

Callers

nothing calls this directly

Calls 6

BorrowEncoderFunction · 0.85
TestWriterErrorTypeAlias · 0.85
EncodeMethod · 0.80
ReleaseMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…