@@ -204,16 +204,16 @@ func TestUnmarshalRawIncompatible(t *testing.T) {
204
204
assert .NotNil (t , err , "expected an error" )
205
205
}
206
206
207
- // func TestUnmarshalZeroesStruct(t *testing.T) {
208
- // data, err := bson.MarshalWithRegistry(mgoRegistry, bson.M{"b": 2})
209
- // assert.Nil(t, err, "expected nil error, got: %v", err)
210
- // type T struct{ A, B int }
211
- // v := T{A: 1}
212
- // err = bson.UnmarshalWithRegistry(mgoRegistry, data, &v)
213
- // assert.Nil(t, err, "expected nil error, got: %v", err)
214
- // assert.Equal(t, 0, v.A, "expected: 0, got: %v", v.A)
215
- // assert.Equal(t, 2, v.B, "expected: 2, got: %v", v.B)
216
- // }
207
+ func TestUnmarshalZeroesStruct (t * testing.T ) {
208
+ data , err := bson .MarshalWithRegistry (mgoRegistry , bson.M {"b" : 2 })
209
+ assert .Nil (t , err , "expected nil error, got: %v" , err )
210
+ type T struct { A , B int }
211
+ v := T {A : 1 }
212
+ err = bson .UnmarshalWithRegistry (mgoRegistry , data , & v )
213
+ assert .Nil (t , err , "expected nil error, got: %v" , err )
214
+ assert .Equal (t , 0 , v .A , "expected: 0, got: %v" , v .A )
215
+ assert .Equal (t , 2 , v .B , "expected: 2, got: %v" , v .B )
216
+ }
217
217
218
218
// func TestUnmarshalZeroesMap(t *testing.T) {
219
219
// data, err := bson.MarshalWithRegistry(mgoRegistry, bson.M{"b": 2})
@@ -226,17 +226,17 @@ func TestUnmarshalRawIncompatible(t *testing.T) {
226
226
// assert.True(t, reflect.DeepEqual(want, m), "expected: %v, got: %v", want, m)
227
227
// }
228
228
229
- // func TestUnmarshalNonNilInterface(t *testing.T) {
230
- // data, err := bson.MarshalWithRegistry(mgoRegistry, bson.M{"b": 2})
231
- // assert.Nil(t, err, "expected nil error, got: %v", err)
232
- // m := bson.M{"a": 1}
233
- // var i interface{}
234
- // i = m
235
- // err = bson.UnmarshalWithRegistry(mgoRegistry, data, &i)
236
- // assert.Nil(t, err, "expected nil error, got: %v", err)
237
- // assert.True(t, reflect.DeepEqual(bson.M{"b": 2}, i), "expected: %v, got: %v", bson.M{"b": 2}, i)
238
- // assert.True(t, reflect.DeepEqual(bson.M{"a": 1}, i ), "expected: %v, got: %v", bson.M{"a": 1}, i )
239
- // }
229
+ func TestUnmarshalNonNilInterface (t * testing.T ) {
230
+ data , err := bson .MarshalWithRegistry (mgoRegistry , bson.M {"b" : 2 })
231
+ assert .Nil (t , err , "expected nil error, got: %v" , err )
232
+ m := bson.M {"a" : 1 }
233
+ var i interface {}
234
+ i = m
235
+ err = bson .UnmarshalWithRegistry (mgoRegistry , data , & i )
236
+ assert .Nil (t , err , "expected nil error, got: %v" , err )
237
+ assert .True (t , reflect .DeepEqual (bson.M {"b" : 2 }, i ), "expected: %v, got: %v" , bson.M {"b" : 2 }, i )
238
+ assert .True (t , reflect .DeepEqual (bson.M {"a" : 1 }, m ), "expected: %v, got: %v" , bson.M {"a" : 1 }, m )
239
+ }
240
240
241
241
func TestPtrInline (t * testing.T ) {
242
242
cases := []struct {
@@ -1354,12 +1354,12 @@ var twoWayCrossItems = []crossTypeItem{
1354
1354
// {&struct{ S string }{"ghi"}, &struct{ S primitive.Symbol }{"ghi"}},
1355
1355
1356
1356
// map <=> struct
1357
- // {&struct {
1358
- // A struct {
1359
- // B, C int
1360
- // }
1361
- // }{struct{ B, C int }{1, 2}},
1362
- // map[string]map[string]int{"a": {"b": 1, "c": 2}}},
1357
+ {& struct {
1358
+ A struct {
1359
+ B , C int
1360
+ }
1361
+ }{struct { B , C int }{1 , 2 }},
1362
+ & map [string ]map [string ]int {"a" : {"b" : 1 , "c" : 2 }}},
1363
1363
1364
1364
// {&struct{ A primitive.Symbol }{"abc"}, &map[string]string{"a": "abc"}},
1365
1365
// {&struct{ A primitive.Symbol }{"abc"}, &map[string][]byte{"a": []byte("abc")}},
@@ -1414,7 +1414,7 @@ var twoWayCrossItems = []crossTypeItem{
1414
1414
{& condTime {}, & map [string ]string {}},
1415
1415
1416
1416
{& condStruct {struct { A []int }{[]int {1 }}}, & bson.M {"v" : bson.M {"a" : []interface {}{1 }}}},
1417
- // {&condStruct{struct{ A []int }{}}, &bson.M{}},
1417
+ {& condStruct {struct { A []int }{}}, & bson.M {}},
1418
1418
1419
1419
// {&condRaw{bson.RawValue{Type: 0x0A, Value: []byte{}}},&bson.M{"v": nil}},
1420
1420
// {&condRaw{bson.RawValue{Type: 0x00}}, &bson.M{}},
@@ -1508,9 +1508,9 @@ var oneWayCrossItems = []crossTypeItem{
1508
1508
{& shortIface {int64 (1 ) << 30 }, & map [string ]interface {}{"v" : 1 << 30 }},
1509
1509
1510
1510
// Ensure omitempty on struct with private fields works properly.
1511
- // {&struct {
1512
- // V struct{ v time.Time } `bson:",omitempty"`
1513
- // }{}, &map[string]interface{}{}},
1511
+ {& struct {
1512
+ V struct { v time.Time } `bson:",omitempty"`
1513
+ }{}, & map [string ]interface {}{}},
1514
1514
1515
1515
// Attempt to marshal slice into RawD (issue #120).
1516
1516
// {bson.M{"x": []int{1, 2, 3}}, &struct{ X bson.Raw }{}},
0 commit comments