From e34f073f7b2a0549df4fa363af7beba05129b769 Mon Sep 17 00:00:00 2001 From: einfachIrgendwer0815 <85333734+einfachIrgendwer0815@users.noreply.github.com> Date: Sat, 16 Mar 2024 11:13:45 +0100 Subject: [PATCH] Test line limits --- tests/examples/too-long-lines.txt | 19 ++++++++ tests/integration_tests.rs | 78 +++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 tests/examples/too-long-lines.txt diff --git a/tests/examples/too-long-lines.txt b/tests/examples/too-long-lines.txt new file mode 100644 index 00000000..c53cfef1 --- /dev/null +++ b/tests/examples/too-long-lines.txt @@ -0,0 +1,19 @@ +a +bb +ccc +dddd +eeeee +ffffff +ggggggg +hhhhhhhh +iiiiiiiii +jjjjjjjjjj +kkkkkkkkk +llllllll +mmmmmmm +nnnnnn +ooooo +pppp +qqq +rr +s diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 0285ac26..e280d5f6 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -307,6 +307,84 @@ fn list_themes_without_colors() { .stdout(predicate::str::contains(default_theme_chunk).normalize()); } +#[test] +fn soft_line_limit() { + bat() + .arg("too-long-lines.txt") + .arg("--soft-line-limit=10") + .arg("--decorations=always") + .arg("--terminal-width=80") + .assert() + .success() + .stdout( + "───────┬──────────────────────────────────────────────────────────────────────── + │ File: too-long-lines.txt +───────┼──────────────────────────────────────────────────────────────────────── + 1 │ a + 2 │ bb + 3 │ ccc + 4 │ dddd + 5 │ eeeee + 6 │ ffffff + 7 │ ggggggg + 8 │ hhhhhhhh + 9 │ iiiiiiiii + 10 ! │ + 11 │ kkkkkkkkk + 12 │ llllllll + 13 │ mmmmmmm + 14 │ nnnnnn + 15 │ ooooo + 16 │ pppp + 17 │ qqq + 18 │ rr + 19 │ s +───────┴──────────────────────────────────────────────────────────────────────── +", + ); +} + +#[test] +fn soft_line_limit_style_plain() { + bat() + .arg("too-long-lines.txt") + .arg("--soft-line-limit=10") + .arg("--style=plain") + .assert() + .success() + .stdout( + "a +bb +ccc +dddd +eeeee +ffffff +ggggggg +hhhhhhhh +iiiiiiiii +kkkkkkkkk +llllllll +mmmmmmm +nnnnnn +ooooo +pppp +qqq +rr +s +", + ); +} + +#[test] +fn hard_line_limit() { + bat() + .arg("too-long-lines.txt") + .arg("--hard-line-limit=10") + .assert() + .failure() + .stderr("\u{1b}[31m[bat error]\u{1b}[0m: Line 10 is too long\n"); +} + #[test] #[cfg_attr(any(not(feature = "git"), target_os = "windows"), ignore)] fn short_help() {