File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -109,3 +109,28 @@ impl fmt::Display for Timestamp {
109
109
formatter ( self . time ) . fmt ( f)
110
110
}
111
111
}
112
+
113
+ #[ cfg( test) ]
114
+ mod tests {
115
+ use super :: Timestamp ;
116
+ use crate :: TimestampPrecision ;
117
+
118
+ #[ test]
119
+ fn test_display_timestamp ( ) {
120
+ let mut ts = Timestamp {
121
+ time : std:: time:: SystemTime :: UNIX_EPOCH ,
122
+ precision : TimestampPrecision :: Nanos ,
123
+ } ;
124
+
125
+ assert_eq ! ( "1970-01-01T00:00:00.000000000Z" , format!( "{ts}" ) ) ;
126
+
127
+ ts. precision = TimestampPrecision :: Micros ;
128
+ assert_eq ! ( "1970-01-01T00:00:00.000000Z" , format!( "{ts}" ) ) ;
129
+
130
+ ts. precision = TimestampPrecision :: Millis ;
131
+ assert_eq ! ( "1970-01-01T00:00:00.000Z" , format!( "{ts}" ) ) ;
132
+
133
+ ts. precision = TimestampPrecision :: Seconds ;
134
+ assert_eq ! ( "1970-01-01T00:00:00Z" , format!( "{ts}" ) ) ;
135
+ }
136
+ }
You can’t perform that action at this time.
0 commit comments