Test line limits

This commit is contained in:
einfachIrgendwer0815 2024-03-16 11:13:45 +01:00
parent 9594b0e4aa
commit e34f073f7b
No known key found for this signature in database
GPG Key ID: 58D55E5F117DA873
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

@ -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 ! <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() {