Better error message when seek fails

> hexyl "$(which hexyl)" --skip=-5gib
    Error: Failed to jump to the desired input position. This could be
    caused by a negative offset that is too large or by an input that is not
    seek-able (e.g. if the input comes from a pipe).

ref: #114
This commit is contained in:
sharkdp authored and David Peter committed 2020-11-01 22:56:59 +01:00
1 parent 66f8508b57
commit 8c3f2230c6
4 files changed
+119 -7

No files matched your search

+21
View File
@@ -84,6 +84,27 @@ fn prints_warning_when_skipping_past_the_end() {
);
}
#[test]
fn can_handle_negative_skip_arguments() {
hexyl()
.arg("hello_world_elf64")
.arg("--color=never")
.arg("--skip=-1KiB")
.assert()
.success();
}
#[test]
fn fails_if_negative_offset_is_too_large() {
hexyl()
.arg("hello_world_elf64")
.arg("--color=never")
.arg("--skip=-1MiB")
.assert()
.failure()
.stderr(predicates::str::contains("Failed to jump"));
}
#[test]
fn fail_if_length_and_bytes_options_are_used_simultaneously() {
hexyl()