@@ -22,6 +22,7 @@ import (
2222 "github.com/google/go-cmp/cmp"
2323 "github.com/mongodb/mongo-go-driver/bson/bsoncodec"
2424 "github.com/mongodb/mongo-go-driver/bson/bsonrw"
25+ "github.com/mongodb/mongo-go-driver/x/bsonx"
2526 "github.com/stretchr/testify/require"
2627 "github.com/tidwall/pretty"
2728)
@@ -161,20 +162,20 @@ func normalizeRelaxedDouble(t *testing.T, key string, rEJ string) string {
161162}
162163
163164// 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 )
167168 expectNoError (t , err , fmt .Sprintf ("%s: decoding %s BSON" , testDesc , bType ))
168169 return doc
169170}
170171
171172// nativeToBSON encodes the native Document (doc) into canonical BSON and compares it to the expected
172173// 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 ) {
174175 actualB := new (bytes.Buffer )
175176 vw , err := bsonrw .NewBSONValueWriter (actualB )
176177 expectNoError (t , err , fmt .Sprintf ("%s: creating ValueWriter" , testDesc ))
177- err = pc .DocumentEncodeValue (ec , vw , doc )
178+ err = pc .x . DocumentEncodeValue (ec , vw , doc )
178179 expectNoError (t , err , fmt .Sprintf ("%s: encoding %s BSON" , testDesc , bType ))
179180
180181 if diff := cmp .Diff (cB , actualB .Bytes ()); diff != "" {
@@ -185,15 +186,15 @@ func nativeToBSON(t *testing.T, cB []byte, doc Doc, testDesc, bType, docSrcDesc
185186}
186187
187188// 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
190191 err := UnmarshalExtJSON ([]byte (ej ), ejType != "relaxed" , & doc )
191192 expectNoError (t , err , fmt .Sprintf ("%s: decoding %s extended JSON" , testDesc , ejType ))
192193 return doc
193194}
194195
195196// 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 ) {
197198 actualEJ , err := MarshalExtJSON (doc , ejType != "relaxed" , true )
198199 expectNoError (t , err , fmt .Sprintf ("%s: encoding %s extended JSON" , testDesc , ejType ))
199200
@@ -298,8 +299,8 @@ func runTest(t *testing.T, file string) {
298299 b , err := hex .DecodeString (d .Bson )
299300 expectNoError (t , err , d .Description )
300301
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 )
303304 expectError (t , err , fmt .Sprintf ("%s: expected decode error" , d .Description ))
304305 }
305306
@@ -316,7 +317,7 @@ func runTest(t *testing.T, file string) {
316317
317318 switch test .BsonType {
318319 case "0x00" :
319- var doc Doc
320+ var doc bsonx. Doc
320321 err := UnmarshalExtJSON ([]byte (s ), true , & doc )
321322 expectError (t , err , fmt .Sprintf ("%s: expected parse error" , p .Description ))
322323 case "0x13" :
0 commit comments