diff --git a/tests/examples/80-columns.txt b/tests/examples/80-columns.txt new file mode 100644 index 00000000..0717aeec --- /dev/null +++ b/tests/examples/80-columns.txt @@ -0,0 +1 @@ +abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyz diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 02e60a75..887e92d4 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -1479,6 +1479,101 @@ fn ignored_suffix_arg() { .stderr(""); } +#[test] +fn no_line_wrapping_when_set_to_never() { + let expected = +"───────┬──────────────────────────────────────────────────────────────────────── + │ File: 80-columns.txt + │ Size: 101 B +───────┼──────────────────────────────────────────────────────────────────────── + 1 │ abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyz +───────┴──────────────────────────────────────────────────────────────────────── +"; + + bat() + .arg("--style=full") + .arg("--decorations=always") + .arg("--wrap=never") + .arg("--terminal-width=80") + .arg("80-columns.txt") + .assert() + .success() + .stdout(expected) + .stderr(""); +} + +#[test] +fn line_wrapping_when_auto() { + let expected = + "───────┬──────────────────────────────────────────────────────────────────────── + │ File: 80-columns.txt + │ Size: 101 B +───────┼──────────────────────────────────────────────────────────────────────── + 1 │ abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstu + │ vxyzabcdefghigklmnopqrstuvxyz +───────┴──────────────────────────────────────────────────────────────────────── +"; + + bat() + .arg("--style=full") + .arg("--decorations=always") + .arg("--wrap=auto") + .arg("--terminal-width=80") + .arg("80-columns.txt") + .assert() + .success() + .stdout(expected) + .stderr(""); +} + +#[test] +fn line_wrapping_with_s_flag() { + let expected = + "───────┬──────────────────────────────────────────────────────────────────────── + │ File: 80-columns.txt + │ Size: 101 B +───────┼──────────────────────────────────────────────────────────────────────── + 1 │ abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstu + │ vxyzabcdefghigklmnopqrstuvxyz +───────┴──────────────────────────────────────────────────────────────────────── +"; + + bat() + .arg("--style=full") + .arg("--decorations=always") + .arg("-S") + .arg("--terminal-width=80") + .arg("80-columns.txt") + .assert() + .success() + .stdout(expected) + .stderr(""); +} + +#[test] +fn chop_long_lines_when_specified() { + let expected = + "───────┬──────────────────────────────────────────────────────────────────────── + │ File: 80-columns.txt + │ Size: 101 B +───────┼──────────────────────────────────────────────────────────────────────── + 1 │ abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstu + │ vxyzabcdefghigklmnopqrstuvxyz +───────┴──────────────────────────────────────────────────────────────────────── +"; + + bat() + .arg("--style=full") + .arg("--decorations=always") + .arg("--chop-long-lines") + .arg("--terminal-width=80") + .arg("80-columns.txt") + .assert() + .success() + .stdout(expected) + .stderr(""); +} + #[test] fn highlighting_is_skipped_on_long_lines() { let expected = "\u{1b}[38;5;231m{\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;208mapi\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;231m:\u{1b}[0m\n".to_owned() +