@@ -10,6 +10,7 @@ import (
10
10
"encoding/json"
11
11
"errors"
12
12
"fmt"
13
+ "math"
13
14
"net/url"
14
15
"reflect"
15
16
"testing"
@@ -21,7 +22,6 @@ import (
21
22
"go.mongodb.org/mongo-driver/bson/bsontype"
22
23
"go.mongodb.org/mongo-driver/bson/primitive"
23
24
"go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
24
- "math"
25
25
)
26
26
27
27
type myInterface interface {
@@ -217,7 +217,7 @@ func TestDefaultValueEncoders(t *testing.T) {
217
217
},
218
218
{
219
219
"MapEncodeValue" ,
220
- ValueEncoderFunc ( dve . MapEncodeValue ) ,
220
+ defaultMapCodec ,
221
221
[]subtest {
222
222
{
223
223
"wrong kind" ,
@@ -227,18 +227,6 @@ func TestDefaultValueEncoders(t *testing.T) {
227
227
bsonrwtest .Nothing ,
228
228
ValueEncoderError {Name : "MapEncodeValue" , Kinds : []reflect.Kind {reflect .Map }, Received : reflect .ValueOf (wrong )},
229
229
},
230
- {
231
- "wrong kind (non-string key)" ,
232
- map [int ]interface {}{},
233
- nil ,
234
- nil ,
235
- bsonrwtest .Nothing ,
236
- ValueEncoderError {
237
- Name : "MapEncodeValue" ,
238
- Kinds : []reflect.Kind {reflect .Map },
239
- Received : reflect .ValueOf (map [int ]interface {}{}),
240
- },
241
- },
242
230
{
243
231
"WriteDocument Error" ,
244
232
map [string ]interface {}{},
@@ -295,6 +283,16 @@ func TestDefaultValueEncoders(t *testing.T) {
295
283
bsonrwtest .WriteDocumentEnd ,
296
284
nil ,
297
285
},
286
+ {
287
+ "non-string key success" ,
288
+ map [int ]interface {}{
289
+ 1 : "foobar" ,
290
+ },
291
+ & EncodeContext {Registry : buildDefaultRegistry ()},
292
+ & bsonrwtest.ValueReaderWriter {},
293
+ bsonrwtest .WriteDocumentEnd ,
294
+ nil ,
295
+ },
298
296
},
299
297
},
300
298
{
0 commit comments