Skip to content

Commit 6848e4a

Browse files
committed
zero remaining time unit test
1 parent 7371ca5 commit 6848e4a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/limits.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,4 +511,23 @@ mod tests {
511511
assert_eq!(first_interval, Duration::from_millis(6));
512512
assert_eq!(num_flashblocks, 143);
513513
}
514+
515+
// ============================================================================
516+
// Zero remaining time -- This happens when FCU arrives after the deadline
517+
// ============================================================================
518+
519+
#[test]
520+
fn zero_time_left() {
521+
// We should get zero flashblocks since there's no time left
522+
let block_time = Duration::from_secs(2);
523+
let remaining_time = Duration::from_millis(0);
524+
let interval = Duration::from_millis(200);
525+
526+
let (num_flashblocks, first_interval) =
527+
partition_time_into_flashblocks(block_time, remaining_time, interval);
528+
529+
// 0 / 200 = 0 with remainder 0
530+
assert_eq!(first_interval, Duration::from_millis(200));
531+
assert_eq!(num_flashblocks, 0);
532+
}
514533
}

0 commit comments

Comments
 (0)