@@ -22,6 +22,7 @@ import (
22
22
"github.com/google/go-cmp/cmp"
23
23
"github.com/mongodb/mongo-go-driver/bson/bsoncodec"
24
24
"github.com/mongodb/mongo-go-driver/bson/bsonrw"
25
+ "github.com/mongodb/mongo-go-driver/x/bsonx"
25
26
"github.com/stretchr/testify/require"
26
27
"github.com/tidwall/pretty"
27
28
)
@@ -161,20 +162,20 @@ func normalizeRelaxedDouble(t *testing.T, key string, rEJ string) string {
161
162
}
162
163
163
164
// bsonToNative decodes the BSON bytes (b) into a native Document
164
- func bsonToNative (t * testing.T , b []byte , bType , testDesc string ) Doc {
165
- var doc Doc
166
- err := pc .DocumentDecodeValue (dc , bsonrw .NewBSONDocumentReader (b ), & doc )
165
+ func bsonToNative (t * testing.T , b []byte , bType , testDesc string ) bsonx. Doc {
166
+ var doc bsonx. Doc
167
+ err := pc .x . DocumentDecodeValue (dc , bsonrw .NewBSONDocumentReader (b ), & doc )
167
168
expectNoError (t , err , fmt .Sprintf ("%s: decoding %s BSON" , testDesc , bType ))
168
169
return doc
169
170
}
170
171
171
172
// nativeToBSON encodes the native Document (doc) into canonical BSON and compares it to the expected
172
173
// canonical BSON (cB)
173
- func nativeToBSON (t * testing.T , cB []byte , doc Doc , testDesc , bType , docSrcDesc string ) {
174
+ func nativeToBSON (t * testing.T , cB []byte , doc bsonx. Doc , testDesc , bType , docSrcDesc string ) {
174
175
actualB := new (bytes.Buffer )
175
176
vw , err := bsonrw .NewBSONValueWriter (actualB )
176
177
expectNoError (t , err , fmt .Sprintf ("%s: creating ValueWriter" , testDesc ))
177
- err = pc .DocumentEncodeValue (ec , vw , doc )
178
+ err = pc .x . DocumentEncodeValue (ec , vw , doc )
178
179
expectNoError (t , err , fmt .Sprintf ("%s: encoding %s BSON" , testDesc , bType ))
179
180
180
181
if diff := cmp .Diff (cB , actualB .Bytes ()); diff != "" {
@@ -185,15 +186,15 @@ func nativeToBSON(t *testing.T, cB []byte, doc Doc, testDesc, bType, docSrcDesc
185
186
}
186
187
187
188
// jsonToNative decodes the extended JSON string (ej) into a native Document
188
- func jsonToNative (t * testing.T , ej , ejType , testDesc string ) Doc {
189
- var doc Doc
189
+ func jsonToNative (t * testing.T , ej , ejType , testDesc string ) bsonx. Doc {
190
+ var doc bsonx. Doc
190
191
err := UnmarshalExtJSON ([]byte (ej ), ejType != "relaxed" , & doc )
191
192
expectNoError (t , err , fmt .Sprintf ("%s: decoding %s extended JSON" , testDesc , ejType ))
192
193
return doc
193
194
}
194
195
195
196
// nativeToJSON encodes the native Document (doc) into an extended JSON string
196
- func nativeToJSON (t * testing.T , ej string , doc Doc , testDesc , ejType , ejShortName , docSrcDesc string ) {
197
+ func nativeToJSON (t * testing.T , ej string , doc bsonx. Doc , testDesc , ejType , ejShortName , docSrcDesc string ) {
197
198
actualEJ , err := MarshalExtJSON (doc , ejType != "relaxed" , true )
198
199
expectNoError (t , err , fmt .Sprintf ("%s: encoding %s extended JSON" , testDesc , ejType ))
199
200
@@ -298,8 +299,8 @@ func runTest(t *testing.T, file string) {
298
299
b , err := hex .DecodeString (d .Bson )
299
300
expectNoError (t , err , d .Description )
300
301
301
- var doc Doc
302
- err = pc .DocumentDecodeValue (dc , bsonrw .NewBSONDocumentReader (b ), & doc )
302
+ var doc bsonx. Doc
303
+ err = pc .x . DocumentDecodeValue (dc , bsonrw .NewBSONDocumentReader (b ), & doc )
303
304
expectError (t , err , fmt .Sprintf ("%s: expected decode error" , d .Description ))
304
305
}
305
306
@@ -316,7 +317,7 @@ func runTest(t *testing.T, file string) {
316
317
317
318
switch test .BsonType {
318
319
case "0x00" :
319
- var doc Doc
320
+ var doc bsonx. Doc
320
321
err := UnmarshalExtJSON ([]byte (s ), true , & doc )
321
322
expectError (t , err , fmt .Sprintf ("%s: expected parse error" , p .Description ))
322
323
case "0x13" :
0 commit comments