Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Modularius committed Feb 4, 2025
1 parent 157eb6f commit 8c77af7
Showing 1 changed file with 40 additions and 16 deletions.
56 changes: 40 additions & 16 deletions digitiser-aggregator/src/frame/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,28 @@ mod test {
assert!(cache.poll().is_none());

assert_eq!(cache.get_num_partial_frames(), 0);
assert!(cache.push(0, &frame_1, EventData::dummy_data(0, 5, &[0, 1, 2])).is_ok());
assert!(cache
.push(0, &frame_1, EventData::dummy_data(0, 5, &[0, 1, 2]))
.is_ok());
assert_eq!(cache.get_num_partial_frames(), 1);

assert!(cache.poll().is_none());

assert!(cache.push(1, &frame_1, EventData::dummy_data(0, 5, &[3, 4, 5])).is_ok());
assert!(cache
.push(1, &frame_1, EventData::dummy_data(0, 5, &[3, 4, 5]))
.is_ok());

assert!(cache.poll().is_none());

assert!(cache.push(4, &frame_1, EventData::dummy_data(0, 5, &[6, 7, 8])).is_ok());
assert!(cache
.push(4, &frame_1, EventData::dummy_data(0, 5, &[6, 7, 8]))
.is_ok());

assert!(cache.poll().is_none());

assert!(cache.push(8, &frame_1, EventData::dummy_data(0, 5, &[9, 10, 11])).is_ok());
assert!(cache
.push(8, &frame_1, EventData::dummy_data(0, 5, &[9, 10, 11]))
.is_ok());

{
let frame = cache.poll().unwrap();
Expand Down Expand Up @@ -200,15 +208,21 @@ mod test {

assert!(cache.poll().is_none());

assert!(cache.push(0, &frame_1, EventData::dummy_data(0, 5, &[0, 1, 2])).is_ok());
assert!(cache
.push(0, &frame_1, EventData::dummy_data(0, 5, &[0, 1, 2]))
.is_ok());

assert!(cache.poll().is_none());

assert!(cache.push(1, &frame_1, EventData::dummy_data(0, 5, &[3, 4, 5])).is_ok());
assert!(cache
.push(1, &frame_1, EventData::dummy_data(0, 5, &[3, 4, 5]))
.is_ok());

assert!(cache.poll().is_none());

assert!(cache.push(8, &frame_1, EventData::dummy_data(0, 5, &[9, 10, 11])).is_ok());
assert!(cache
.push(8, &frame_1, EventData::dummy_data(0, 5, &[9, 10, 11]))
.is_ok());

assert!(cache.poll().is_none());

Expand Down Expand Up @@ -254,20 +268,26 @@ mod test {
frame_number: 1728,
veto_flags: 4,
};
assert!(cache.push(0, &frame_1, EventData::dummy_data(0, 5, &[0, 1, 2])).is_ok());
assert!(cache.push(1, &frame_1, EventData::dummy_data(0, 5, &[3, 4, 5])).is_ok());
assert!(cache.push(8, &frame_1, EventData::dummy_data(0, 5, &[9, 10, 11])).is_ok());
assert!(cache
.push(0, &frame_1, EventData::dummy_data(0, 5, &[0, 1, 2]))
.is_ok());
assert!(cache
.push(1, &frame_1, EventData::dummy_data(0, 5, &[3, 4, 5]))
.is_ok());
assert!(cache
.push(8, &frame_1, EventData::dummy_data(0, 5, &[9, 10, 11]))
.is_ok());

tokio::time::sleep(Duration::from_millis(105)).await;

let _ = cache.poll().unwrap();

// This call to push should return an error
assert!(cache.push(4, &frame_1, EventData::dummy_data(0, 5, &[6, 7, 8])).is_err());
assert!(cache
.push(4, &frame_1, EventData::dummy_data(0, 5, &[6, 7, 8]))
.is_err());
}



#[test]
fn test_metadata_equality() {
let mut cache = FrameCache::<EventData>::new(Duration::from_millis(100), vec![1, 2]);
Expand Down Expand Up @@ -296,11 +316,15 @@ mod test {
assert_eq!(cache.frames.len(), 0);
assert!(cache.poll().is_none());

assert!(cache.push(1, &frame_1, EventData::dummy_data(0, 5, &[0, 1, 2])).is_ok());
assert!(cache
.push(1, &frame_1, EventData::dummy_data(0, 5, &[0, 1, 2]))
.is_ok());
assert_eq!(cache.frames.len(), 1);
assert!(cache.poll().is_none());

assert!(cache.push(2, &frame_2, EventData::dummy_data(0, 5, &[0, 1, 2])).is_ok());
assert!(cache
.push(2, &frame_2, EventData::dummy_data(0, 5, &[0, 1, 2]))
.is_ok());
assert_eq!(cache.frames.len(), 1);
assert!(cache.poll().is_some());
}
Expand Down

0 comments on commit 8c77af7

Please sign in to comment.