(t *testing.T)
| 129 | } |
| 130 | |
| 131 | func TestEncoderArrayEncodeAPI(t *testing.T) { |
| 132 | t.Run("array-interfaces", func(t *testing.T) { |
| 133 | v := &testEncodingArrInterfaces{ |
| 134 | 1, |
| 135 | int64(1), |
| 136 | int32(1), |
| 137 | int16(1), |
| 138 | int8(1), |
| 139 | uint64(1), |
| 140 | uint32(1), |
| 141 | uint16(1), |
| 142 | uint8(1), |
| 143 | float64(1.31), |
| 144 | // float32(1.31), |
| 145 | &TestEncodingArr{}, |
| 146 | true, |
| 147 | "test", |
| 148 | &TestEncoding{ |
| 149 | test: "hello world", |
| 150 | test2: "foobar", |
| 151 | testInt: 1, |
| 152 | testBool: true, |
| 153 | }, |
| 154 | } |
| 155 | builder := &strings.Builder{} |
| 156 | enc := BorrowEncoder(builder) |
| 157 | defer enc.Release() |
| 158 | err := enc.EncodeArray(v) |
| 159 | assert.Nil(t, err, "Error should be nil") |
| 160 | assert.Equal( |
| 161 | t, |
| 162 | `[1,1,1,1,1,1,1,1,1.31,[],true,"test",{"test":"hello world","test2":"foobar","testInt":1,"testBool":true,"testArr":[],"testF64":0,"testF32":0,"sub":{}}]`, |
| 163 | builder.String(), |
| 164 | "Result of marshalling is different as the one expected") |
| 165 | }) |
| 166 | |
| 167 | t.Run("array-interfaces-write-error", func(t *testing.T) { |
| 168 | v := &testEncodingArrInterfaces{} |
| 169 | w := TestWriterError("") |
| 170 | enc := BorrowEncoder(w) |
| 171 | defer enc.Release() |
| 172 | err := enc.EncodeArray(v) |
| 173 | assert.NotNil(t, err, "err should not be nil") |
| 174 | }) |
| 175 | } |
| 176 | |
| 177 | // Array add with omit key tests |
| 178 |
nothing calls this directly
no test coverage detected
searching dependent graphs…