diff --git a/src/bin/hexyl.rs b/src/bin/hexyl.rs index 849dc7c..597e5cd 100644 --- a/src/bin/hexyl.rs +++ b/src/bin/hexyl.rs @@ -46,6 +46,7 @@ fn run() -> Result<(), AnyhowError> { .long("bytes") .takes_value(true) .value_name("N") + .conflicts_with("length") .help("An alias for -n/--length"), ) .arg( diff --git a/tests/examples/hello_world_elf64 b/tests/examples/hello_world_elf64 new file mode 100755 index 0000000..1257b9d Binary files /dev/null and b/tests/examples/hello_world_elf64 differ diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index accfe44..e8b9462 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -25,6 +25,32 @@ fn fails_on_non_existing_input() { 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] fn display_offset() { hexyl()