mirror of
https://github.com/sharkdp/bat.git
synced 2025-01-31 10:11:07 +00:00
Added helper function for -S flag tests
This commit is contained in:
parent
20f272168a
commit
bf114f5844
@ -1499,78 +1499,45 @@ fn ignored_suffix_arg() {
|
|||||||
.stderr("");
|
.stderr("");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
fn wrapping_test(wrap_flag: &str, expect_wrap: bool) {
|
||||||
fn no_line_wrapping_when_set_to_never() {
|
let expected = match expect_wrap {
|
||||||
let expected = "abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyz
|
true =>
|
||||||
";
|
"abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcde\nfghigklmnopqrstuvxyz\n",
|
||||||
|
false =>
|
||||||
|
"abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyz\n",
|
||||||
|
};
|
||||||
|
|
||||||
bat()
|
bat()
|
||||||
|
.arg(wrap_flag)
|
||||||
.arg("--style=rule")
|
.arg("--style=rule")
|
||||||
.arg("--color=never")
|
.arg("--color=never")
|
||||||
.arg("--decorations=always")
|
.arg("--decorations=always")
|
||||||
.arg("--wrap=never")
|
|
||||||
.arg("--terminal-width=80")
|
.arg("--terminal-width=80")
|
||||||
.arg("80-columns.txt")
|
.arg("long-single-line.txt")
|
||||||
.assert()
|
.assert()
|
||||||
.success()
|
.success()
|
||||||
.stdout(expected)
|
.stdout(expected.to_owned())
|
||||||
.stderr("");
|
.stderr("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn no_line_wrapping_when_set_to_never() {
|
||||||
|
wrapping_test("--wrap=never", false);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn line_wrapping_when_auto() {
|
fn line_wrapping_when_auto() {
|
||||||
let expected =
|
wrapping_test("--wrap=auto", true);
|
||||||
"abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcde
|
|
||||||
fghigklmnopqrstuvxyz
|
|
||||||
";
|
|
||||||
|
|
||||||
bat()
|
|
||||||
.arg("--color=never")
|
|
||||||
.arg("--style=rule")
|
|
||||||
.arg("--decorations=always")
|
|
||||||
.arg("--wrap=auto")
|
|
||||||
.arg("--terminal-width=80")
|
|
||||||
.arg("80-columns.txt")
|
|
||||||
.assert()
|
|
||||||
.success()
|
|
||||||
.stdout(expected)
|
|
||||||
.stderr("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_line_wrapping_with_s_flag() {
|
fn no_line_wrapping_with_s_flag() {
|
||||||
let expected =
|
wrapping_test("-S", false);
|
||||||
"abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyz\n";
|
|
||||||
|
|
||||||
bat()
|
|
||||||
.arg("--color=never")
|
|
||||||
.arg("--style=rule")
|
|
||||||
.arg("--decorations=always")
|
|
||||||
.arg("-S")
|
|
||||||
.arg("--terminal-width=80")
|
|
||||||
.arg("80-columns.txt")
|
|
||||||
.assert()
|
|
||||||
.success()
|
|
||||||
.stdout(expected)
|
|
||||||
.stderr("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_wrapping_with_chop_long_lines() {
|
fn no_wrapping_with_chop_long_lines() {
|
||||||
let expected =
|
wrapping_test("--chop-long-lines", false);
|
||||||
"abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyz\n";
|
|
||||||
|
|
||||||
bat()
|
|
||||||
.arg("--color=never")
|
|
||||||
.arg("--style=rule")
|
|
||||||
.arg("--decorations=always")
|
|
||||||
.arg("--chop-long-lines")
|
|
||||||
.arg("--terminal-width=80")
|
|
||||||
.arg("80-columns.txt")
|
|
||||||
.assert()
|
|
||||||
.success()
|
|
||||||
.stdout(expected)
|
|
||||||
.stderr("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user