Skip to content

Commit

Permalink
tests: Sanity check for invalid UTF8 test
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpovel committed Mar 21, 2024
1 parent c0354c2 commit f55bdf7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,18 @@ Duebel
}

#[test]
#[should_panic]
fn test_cli_on_invalid_utf8() {
let mut cmd = get_cmd();

let input = b"invalid utf8 \xFF";

#[allow(invalid_from_utf8)] // Attribute didn't work on `assert` macro?
let check = std::str::from_utf8(input);
assert!(check.is_err(), "Input is valid UTF8, test is broken");

cmd.write_stdin(*input);

cmd.assert().success();
cmd.assert().failure();
}

fn get_cmd() -> Command {
Expand Down

0 comments on commit f55bdf7

Please sign in to comment.