mirror of
https://github.com/sharkdp/hexyl.git
synced 2026-10-28 08:05:52 +00:00
Organize integration tests into modules
This commit is contained in:
1 parent
8c3f2230c6
commit
1db77094da
1 file changed
+49
-23
+49
-23
@@ -6,6 +6,9 @@ fn hexyl() -> Command {
|
||||
cmd
|
||||
}
|
||||
|
||||
mod basic {
|
||||
use super::hexyl;
|
||||
|
||||
#[test]
|
||||
fn can_print_simple_ascii_file() {
|
||||
hexyl()
|
||||
@@ -39,6 +42,24 @@ fn fails_on_non_existing_input() {
|
||||
hexyl().arg("non-existing").assert().failure();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn prints_warning_on_empty_content() {
|
||||
hexyl()
|
||||
.arg("empty")
|
||||
.arg("--color=never")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(
|
||||
"┌────────┬─────────────────────────┬─────────────────────────┬────────┬────────┐\n\
|
||||
│ │ No content to print │ │ │ │\n\
|
||||
└────────┴─────────────────────────┴─────────────────────────┴────────┴────────┘\n",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
mod length {
|
||||
use super::hexyl;
|
||||
|
||||
#[test]
|
||||
fn length_restricts_output_size() {
|
||||
hexyl()
|
||||
@@ -56,18 +77,18 @@ fn length_restricts_output_size() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn prints_warning_on_empty_content() {
|
||||
fn fail_if_length_and_bytes_options_are_used_simultaneously() {
|
||||
hexyl()
|
||||
.arg("empty")
|
||||
.arg("--color=never")
|
||||
.arg("hello_world_elf64")
|
||||
.arg("--length=32")
|
||||
.arg("--bytes=10")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(
|
||||
"┌────────┬─────────────────────────┬─────────────────────────┬────────┬────────┐\n\
|
||||
│ │ No content to print │ │ │ │\n\
|
||||
└────────┴─────────────────────────┴─────────────────────────┴────────┴────────┘\n",
|
||||
);
|
||||
.failure();
|
||||
}
|
||||
}
|
||||
|
||||
mod skip {
|
||||
use super::hexyl;
|
||||
|
||||
#[test]
|
||||
fn prints_warning_when_skipping_past_the_end() {
|
||||
@@ -85,13 +106,19 @@ fn prints_warning_when_skipping_past_the_end() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_handle_negative_skip_arguments() {
|
||||
fn can_handle_negative_arguments() {
|
||||
hexyl()
|
||||
.arg("hello_world_elf64")
|
||||
.arg("ascii")
|
||||
.arg("--color=never")
|
||||
.arg("--skip=-1KiB")
|
||||
.arg("--skip=2")
|
||||
.arg("--length=4")
|
||||
.assert()
|
||||
.success();
|
||||
.success()
|
||||
.stdout(
|
||||
"┌────────┬─────────────────────────┬─────────────────────────┬────────┬────────┐\n\
|
||||
│00000002│ 63 64 65 66 ┊ │cdef ┊ │\n\
|
||||
└────────┴─────────────────────────┴─────────────────────────┴────────┴────────┘\n",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -104,19 +131,13 @@ fn fails_if_negative_offset_is_too_large() {
|
||||
.failure()
|
||||
.stderr(predicates::str::contains("Failed to jump"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fail_if_length_and_bytes_options_are_used_simultaneously() {
|
||||
hexyl()
|
||||
.arg("hello_world_elf64")
|
||||
.arg("--length=32")
|
||||
.arg("--bytes=10")
|
||||
.assert()
|
||||
.failure();
|
||||
}
|
||||
|
||||
mod display_offset {
|
||||
use super::hexyl;
|
||||
|
||||
#[test]
|
||||
fn display_offset() {
|
||||
fn basic() {
|
||||
hexyl()
|
||||
.arg("ascii")
|
||||
.arg("--color=never")
|
||||
@@ -146,6 +167,10 @@ fn display_offset_and_skip() {
|
||||
└────────┴─────────────────────────┴─────────────────────────┴────────┴────────┘\n",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
mod blocksize {
|
||||
use super::hexyl;
|
||||
|
||||
#[test]
|
||||
fn fails_for_zero_or_negative_blocksize() {
|
||||
@@ -161,3 +186,4 @@ fn fails_for_zero_or_negative_blocksize() {
|
||||
.assert()
|
||||
.failure();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user