1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-01 19:02:22 +01:00

Test line limits

This commit is contained in:
einfachIrgendwer0815
2024-03-16 11:13:45 +01:00
parent f7f00c8e15
commit 491dac5538
2 changed files with 97 additions and 0 deletions

19
tests/examples/too-long-lines.txt vendored Normal file
View File

@@ -0,0 +1,19 @@
a
bb
ccc
dddd
eeeee
ffffff
ggggggg
hhhhhhhh
iiiiiiiii
jjjjjjjjjj
kkkkkkkkk
llllllll
mmmmmmm
nnnnnn
ooooo
pppp
qqq
rr
s

View File

@@ -312,6 +312,84 @@ fn list_themes_to_piped_output() {
.stdout(predicate::str::contains("(default)").not());
}
#[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 ! │ <line too long>
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() {