mirror of
https://github.com/sharkdp/hexyl.git
synced 2026-10-26 20:16:31 +00:00
Add simple integration tests
This commit is contained in:
1 parent
cc5b308fc9
commit
09c22e09b9
4 files changed
+167
-57
No files matched your search
@@ -0,0 +1 @@
|
||||
abcdefgh!?%&/()
|
||||
@@ -0,0 +1,41 @@
|
||||
use assert_cmd::Command;
|
||||
|
||||
fn hexyl() -> Command {
|
||||
let mut cmd = Command::cargo_bin("hexyl").unwrap();
|
||||
cmd.current_dir("tests/examples");
|
||||
cmd
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_print_simple_ascii_file() {
|
||||
hexyl()
|
||||
.arg("ascii")
|
||||
.arg("--color=never")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(
|
||||
"┌────────┬─────────────────────────┬─────────────────────────┬────────┬────────┐\n\
|
||||
│00000000│ 61 62 63 64 65 66 67 68 ┊ 21 3f 25 26 2f 28 29 0a │abcdefgh┊!?%&/()_│\n\
|
||||
└────────┴─────────────────────────┴─────────────────────────┴────────┴────────┘\n",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fails_on_non_existing_input() {
|
||||
hexyl().arg("non-existing").assert().failure();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn display_offset() {
|
||||
hexyl()
|
||||
.arg("ascii")
|
||||
.arg("--color=never")
|
||||
.arg("--display-offset=0xc0ffee")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(
|
||||
"┌────────┬─────────────────────────┬─────────────────────────┬────────┬────────┐\n\
|
||||
│00c0ffee│ 61 62 63 64 65 66 67 68 ┊ 21 3f 25 26 2f 28 29 0a │abcdefgh┊!?%&/()_│\n\
|
||||
└────────┴─────────────────────────┴─────────────────────────┴────────┴────────┘\n",
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user