Skip to content

Commit 7e4b2d6

Browse files
committed
- added more test to struct_codec_test.go for make sure Zeroer's pointer with nil value should be zero
1 parent a9d23e1 commit 7e4b2d6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

bson/bsoncodec/struct_codec_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package bsoncodec
88

99
import (
1010
"testing"
11+
//"time"
1112

1213
"github.com/stretchr/testify/assert"
1314
)
@@ -35,4 +36,12 @@ func TestZeoerInterfaceUsedByDecoder(t *testing.T) {
3536

3637
z.reportZero = true
3738
assert.True(t, enc.isZero(z))
39+
40+
// *time.Time with nil should be zero
41+
var tp *time.Time
42+
assert.True(t, enc.isZero(tp))
43+
44+
// actually all zeroer if nil should also be zero
45+
var zp *zeroTest
46+
assert.True(t, enc.isZero(zp))
3847
}

0 commit comments

Comments
 (0)