Skip to content

Commit b7c48f5

Browse files
author
delioda
committed
rebased and moved the test in the new bsoncodec folder
1 parent 71de844 commit b7c48f5

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

bson/bsoncodec/bsoncodec_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,28 @@ func TestTimeRoundTrip(t *testing.T) {
7575
t.Errorf("Did not get zero time as expected.")
7676
}
7777
}
78+
79+
func TestNonNullTimeRoundTrip(t *testing.T) {
80+
now := time.Now()
81+
now = time.Unix(now.Unix(), 0)
82+
val := struct {
83+
Value time.Time
84+
ID string
85+
}{
86+
ID: "time-rt-test",
87+
Value: now,
88+
}
89+
90+
bsonOut, err := Marshal(val)
91+
noerr(t, err)
92+
rtval := struct {
93+
Value time.Time
94+
ID string
95+
}{}
96+
97+
err = Unmarshal(bsonOut, &rtval)
98+
noerr(t, err)
99+
if !cmp.Equal(val, rtval) {
100+
t.Errorf("Did not round trip properly. got %v; want %v", val, rtval)
101+
}
102+
}

0 commit comments

Comments
 (0)