Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
van-sprundel committed Oct 14, 2024
1 parent 673acda commit 82765a0
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/system/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -691,33 +691,25 @@ mod tests {
// valid header should remain valid
let c = tempfile_with_data(&[0xD0, 0x50, 0x01, 0x00]).unwrap();
let timeout = Duration::seconds(30);
assert!(
SessionRecordFile::new(test_user_id(), c.try_clone().unwrap(), timeout).is_ok()
);
assert!(SessionRecordFile::new(test_user_id(), c.try_clone().unwrap(), timeout).is_ok());
let v = data_from_tempfile(c).unwrap();
assert_eq!(&v[..], &[0xD0, 0x50, 0x01, 0x00]);

// invalid headers should be corrected
let c = tempfile_with_data(&[0xAB, 0xBA]).unwrap();
assert!(
SessionRecordFile::new(test_user_id(), c.try_clone().unwrap(), timeout).is_ok()
);
assert!(SessionRecordFile::new(test_user_id(), c.try_clone().unwrap(), timeout).is_ok());
let v = data_from_tempfile(c).unwrap();
assert_eq!(&v[..], &[0xD0, 0x50, 0x01, 0x00]);

// empty header should be filled in
let c = tempfile_with_data(&[]).unwrap();
assert!(
SessionRecordFile::new(test_user_id(), c.try_clone().unwrap(), timeout).is_ok()
);
assert!(SessionRecordFile::new(test_user_id(), c.try_clone().unwrap(), timeout).is_ok());
let v = data_from_tempfile(c).unwrap();
assert_eq!(&v[..], &[0xD0, 0x50, 0x01, 0x00]);

// invalid version should reset file
let c = tempfile_with_data(&[0xD0, 0x50, 0xAB, 0xBA, 0x0, 0x0]).unwrap();
assert!(
SessionRecordFile::new(test_user_id(), c.try_clone().unwrap(), timeout).is_ok()
);
assert!(SessionRecordFile::new(test_user_id(), c.try_clone().unwrap(), timeout).is_ok());
let v = data_from_tempfile(c).unwrap();
assert_eq!(&v[..], &[0xD0, 0x50, 0x01, 0x00]);
}
Expand Down

0 comments on commit 82765a0

Please sign in to comment.