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 763b171 commit 309520bCopy full SHA for 309520b
crates/matrix-sdk-sqlite/src/utils.rs
@@ -396,6 +396,8 @@ pub(crate) fn time_to_timestamp(time: SystemTime) -> i64 {
396
397
#[cfg(test)]
398
mod unit_tests {
399
+ use std::time::Duration;
400
+
401
use super::*;
402
403
#[test]
@@ -410,4 +412,13 @@ mod unit_tests {
410
412
fn generating_zero_vars_panics() {
411
413
repeat_vars(0);
414
}
415
416
+ #[test]
417
+ fn test_time_to_timestamp() {
418
+ assert_eq!(time_to_timestamp(SystemTime::UNIX_EPOCH), 0);
419
+ assert_eq!(time_to_timestamp(SystemTime::UNIX_EPOCH + Duration::from_secs(60)), 60);
420
421
+ // Fallback value on overflow.
422
+ assert_eq!(time_to_timestamp(SystemTime::UNIX_EPOCH - Duration::from_secs(60)), 0);
423
+ }
424
0 commit comments