(t *testing.T)
| 70 | } |
| 71 | |
| 72 | func TestEncoderNumberEncodeAPIErrors(t *testing.T) { |
| 73 | t.Run("encode-int-pool-error", func(t *testing.T) { |
| 74 | builder := &strings.Builder{} |
| 75 | enc := NewEncoder(builder) |
| 76 | enc.isPooled = 1 |
| 77 | defer func() { |
| 78 | err := recover() |
| 79 | assert.NotNil(t, err, "err should not be nil") |
| 80 | assert.IsType(t, InvalidUsagePooledEncoderError(""), err, "err should be of type InvalidUsagePooledEncoderError") |
| 81 | }() |
| 82 | _ = enc.EncodeInt(1) |
| 83 | assert.True(t, false, "should not be called as encoder should have panicked") |
| 84 | }) |
| 85 | t.Run("encode-int-write-error", func(t *testing.T) { |
| 86 | w := TestWriterError("") |
| 87 | enc := NewEncoder(w) |
| 88 | err := enc.EncodeInt(1) |
| 89 | assert.NotNil(t, err, "err should not be nil") |
| 90 | assert.Equal(t, "Test Error", err.Error(), "err should be of type InvalidUsagePooledEncoderError") |
| 91 | }) |
| 92 | t.Run("encode-int64-pool-error", func(t *testing.T) { |
| 93 | builder := &strings.Builder{} |
| 94 | enc := NewEncoder(builder) |
| 95 | enc.isPooled = 1 |
| 96 | defer func() { |
| 97 | err := recover() |
| 98 | assert.NotNil(t, err, "err should not be nil") |
| 99 | assert.IsType(t, InvalidUsagePooledEncoderError(""), err, "err should be of type InvalidUsagePooledEncoderError") |
| 100 | }() |
| 101 | _ = enc.EncodeInt64(1) |
| 102 | assert.True(t, false, "should not be called as encoder should have panicked") |
| 103 | }) |
| 104 | t.Run("encode-int64-write-error", func(t *testing.T) { |
| 105 | w := TestWriterError("") |
| 106 | enc := NewEncoder(w) |
| 107 | err := enc.EncodeInt64(1) |
| 108 | assert.NotNil(t, err, "err should not be nil") |
| 109 | assert.Equal(t, "Test Error", err.Error(), "err should be of type InvalidUsagePooledEncoderError") |
| 110 | |
| 111 | }) |
| 112 | t.Run("encode-uint64-pool-error", func(t *testing.T) { |
| 113 | builder := &strings.Builder{} |
| 114 | enc := NewEncoder(builder) |
| 115 | enc.isPooled = 1 |
| 116 | defer func() { |
| 117 | err := recover() |
| 118 | assert.NotNil(t, err, "err should not be nil") |
| 119 | assert.IsType(t, InvalidUsagePooledEncoderError(""), err, "err should be of type InvalidUsagePooledEncoderError") |
| 120 | }() |
| 121 | _ = enc.EncodeUint64(1) |
| 122 | assert.True(t, false, "should not be called as encoder should have panicked") |
| 123 | }) |
| 124 | t.Run("encode-unt64-write-error", func(t *testing.T) { |
| 125 | w := TestWriterError("") |
| 126 | enc := NewEncoder(w) |
| 127 | err := enc.EncodeUint64(1) |
| 128 | assert.NotNil(t, err, "err should not be nil") |
| 129 | assert.Equal(t, "Test Error", err.Error(), "err should be of type InvalidUsagePooledEncoderError") |
nothing calls this directly
no test coverage detected
searching dependent graphs…