We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 71de844 commit b7c48f5Copy full SHA for b7c48f5
bson/bsoncodec/bsoncodec_test.go
@@ -75,3 +75,28 @@ func TestTimeRoundTrip(t *testing.T) {
75
t.Errorf("Did not get zero time as expected.")
76
}
77
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
94
95
+ }{}
96
97
+ err = Unmarshal(bsonOut, &rtval)
98
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