mirror of
https://github.com/sharkdp/hexyl.git
synced 2026-10-30 09:05:54 +00:00
Add test for --length, fix #105
This commit is contained in:
1 parent
09c22e09b9
commit
bb6a3c0650
3 files changed
+27
No files matched your search
@@ -46,6 +46,7 @@ fn run() -> Result<(), AnyhowError> {
|
|||||||
.long("bytes")
|
.long("bytes")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.value_name("N")
|
.value_name("N")
|
||||||
|
.conflicts_with("length")
|
||||||
.help("An alias for -n/--length"),
|
.help("An alias for -n/--length"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
|
|||||||
Executable
BIN
Binary file not shown.
@@ -25,6 +25,32 @@ fn fails_on_non_existing_input() {
|
|||||||
hexyl().arg("non-existing").assert().failure();
|
hexyl().arg("non-existing").assert().failure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn length_restricts_output_size() {
|
||||||
|
hexyl()
|
||||||
|
.arg("hello_world_elf64")
|
||||||
|
.arg("--color=never")
|
||||||
|
.arg("--length=32")
|
||||||
|
.assert()
|
||||||
|
.success()
|
||||||
|
.stdout(
|
||||||
|
"┌────────┬─────────────────────────┬─────────────────────────┬────────┬────────┐\n\
|
||||||
|
│00000000│ 7f 45 4c 46 02 01 01 00 ┊ 00 00 00 00 00 00 00 00 │•ELF•••0┊00000000│\n\
|
||||||
|
│00000010│ 02 00 3e 00 01 00 00 00 ┊ 00 10 40 00 00 00 00 00 │•0>0•000┊0•@00000│\n\
|
||||||
|
└────────┴─────────────────────────┴─────────────────────────┴────────┴────────┘\n",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn fail_if_length_and_bytes_options_are_used_simultaneously() {
|
||||||
|
hexyl()
|
||||||
|
.arg("hello_world_elf64")
|
||||||
|
.arg("--length=32")
|
||||||
|
.arg("--bytes=10")
|
||||||
|
.assert()
|
||||||
|
.failure();
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn display_offset() {
|
fn display_offset() {
|
||||||
hexyl()
|
hexyl()
|
||||||
|
|||||||
Reference in new issue
Block a user