Skip to content

Commit

Permalink
Make test sleeps slightly longer to avoid some trailing sleeps not tr…
Browse files Browse the repository at this point in the history
…igger a spacer.
  • Loading branch information
samwho committed Jun 25, 2023
1 parent 9ca7b00 commit fb7ef3a
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,14 @@ mod tests {
}

#[test_case(vec![], vec![] ; "no output")]
#[test_case(vec![Sleep(150)], vec![] ; "no output, after sleep")]
#[test_case(vec![Sleep(200)], vec![] ; "no output, after sleep")]
#[test_case(
vec![WriteLn("foo"), Sleep(150)],
vec![WriteLn("foo"), Sleep(200)],
vec![Line("foo"), Spacer]
; "single line"
)]
#[test_case(
vec![WriteLn("foo"), Sleep(150), WriteLn("bar"), WriteLn("baz"), Sleep(150)],
vec![WriteLn("foo"), Sleep(200), WriteLn("bar"), WriteLn("baz"), Sleep(200)],
vec![Line("foo"), Spacer, Line("bar"), Line("baz"), Spacer]
; "multiple lines"
)]
Expand All @@ -339,7 +339,7 @@ mod tests {
; "multiple lines, no sleeps"
)]
#[test_case(
vec![Write("foo"), Write("bar"), Sleep(150), WriteLn("baz")],
vec![Write("foo"), Write("bar"), Sleep(200), WriteLn("baz")],
vec![Line("foobarbaz")]
; "single line, sleep in the middle"
)]
Expand Down Expand Up @@ -369,7 +369,13 @@ mod tests {

let output = String::from_utf8(output)?;
let lines = output.lines().collect::<Vec<_>>();
assert_eq!(lines.len(), out.len());
assert_eq!(
lines.len(),
out.len(),
"wrong number of lines, expected {} got {:?}",
out.len(),
lines
);
for (line, out) in lines.iter().zip(out.iter()) {
match out {
Line(expected) => assert_eq!(line, expected),
Expand Down

0 comments on commit fb7ef3a

Please sign in to comment.