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

Function TestEncoderStringEncodeAPIErrors

encode_string_test.go:121–143  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

119}
120
121func TestEncoderStringEncodeAPIErrors(t *testing.T) {
122 t.Run("pool-error", func(t *testing.T) {
123 v := ""
124 enc := BorrowEncoder(nil)
125 enc.isPooled = 1
126 defer func() {
127 err := recover()
128 assert.NotNil(t, err, "err shouldnt be nil")
129 assert.IsType(t, InvalidUsagePooledEncoderError(""), err, "err should be of type InvalidUsagePooledEncoderError")
130 assert.Equal(t, "Invalid usage of pooled encoder", err.(InvalidUsagePooledEncoderError).Error(), "err should be of type InvalidUsagePooledDecoderError")
131 }()
132 _ = enc.EncodeString(v)
133 assert.True(t, false, "should not be called as it should have panicked")
134 })
135 t.Run("write-error", func(t *testing.T) {
136 v := "test"
137 w := TestWriterError("")
138 enc := BorrowEncoder(w)
139 defer enc.Release()
140 err := enc.EncodeString(v)
141 assert.NotNil(t, err, "err should not be nil")
142 })
143}
144
145func TestEncoderStringMarshalAPI(t *testing.T) {
146 t.Run("basic", func(t *testing.T) {

Callers

nothing calls this directly

Calls 6

BorrowEncoderFunction · 0.85
TestWriterErrorTypeAlias · 0.85
EncodeStringMethod · 0.80
ErrorMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…