summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreinfachIrgendwer0815 <85333734+einfachIrgendwer0815@users.noreply.github.com>2023-09-10 14:33:48 +0200
committereinfachIrgendwer0815 <85333734+einfachIrgendwer0815@users.noreply.github.com>2024-02-24 13:51:44 +0100
commit2323aa0defe3f364bcd54ab662a12049141a322d (patch)
treed93f14573c2e4ca00b3524b7d8fc7c09261f5405
parent6c2ce631018e3ea838bed85d956df705d9c297a1 (diff)
Add tests for `--squeeze`
-rw-r--r--tests/examples/empty_lines.txt30
-rw-r--r--tests/integration_tests.rs64
2 files changed, 94 insertions, 0 deletions
diff --git a/tests/examples/empty_lines.txt b/tests/examples/empty_lines.txt
new file mode 100644
index 00000000..8ec1fae8
--- /dev/null
+++ b/tests/examples/empty_lines.txt
@@ -0,0 +1,30 @@
+line 1
+
+
+
+line 5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+line 20
+line 21
+
+
+line 24
+
+line 26
+
+
+
+line 30
diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs
index 3612654b..4d595031 100644
--- a/tests/integration_tests.rs
+++ b/tests/integration_tests.rs
@@ -209,6 +209,70 @@ fn line_range_multiple() {
}
#[test]
+fn squeeze() {
+ bat()
+ .arg("empty_lines.txt")
+ .arg("--squeeze")
+ .assert()
+ .success()
+ .stdout("line 1\n\nline 5\n\nline 20\nline 21\n\nline 24\n\nline 26\n\nline 30\n");
+}
+
+#[test]
+fn squeeze_line_numbers() {
+ bat()
+ .arg("empty_lines.txt")
+ .arg("--squeeze")
+ .arg("--decorations=always")
+ .arg("--number")
+ .assert()
+ .success()
+ .stdout(" 1 line 1\n 2 \n 5 line 5\n 6 \n 20 line 20\n 21 line 21\n 22 \n 24 line 24\n 25 \n 26 line 26\n 27 \n 30 line 30\n");
+}
+
+#[test]
+fn squeeze_limit() {
+ bat()
+ .arg("empty_lines.txt")
+ .arg("--squeeze")
+ .arg("--squeeze-limit=2")
+ .assert()
+ .success()
+ .stdout("line 1\n\n\nline 5\n\n\nline 20\nline 21\n\n\nline 24\n\nline 26\n\n\nline 30\n");
+
+ bat()
+ .arg("empty_lines.txt")
+ .arg("--squeeze")
+ .arg("--squeeze-limit=5")
+ .assert()
+ .success()
+ .stdout("line 1\n\n\n\nline 5\n\n\n\n\n\nline 20\nline 21\n\n\nline 24\n\nline 26\n\n\n\nline 30\n");
+}
+
+#[test]
+fn squeeze_limit_line_numbers() {
+ bat()
+ .arg("empty_lines.txt")
+ .arg("--squeeze")
+ .arg("--squeeze-limit=2")
+ .arg("--decorations=always")
+ .arg("--number")
+ .assert()
+ .success()
+ .stdout(" 1 line 1\n 2 \n 3 \n 5 line 5\n 6 \n 7 \n 20 line 20\n 21 line 21\n 22 \n 23 \n 24 line 24\n 25 \n 26 line 26\n 27 \n 28 \n 30 line 30\n");
+
+ bat()
+ .arg("empty_lines.txt")
+ .arg("--squeeze")
+ .arg("--squeeze-limit=5")
+ .arg("--decorations=always")
+ .arg("--number")
+ .assert()
+ .success()
+ .stdout(" 1 line 1\n 2 \n 3 \n 4 \n 5 line 5\n 6 \n 7 \n 8 \n 9 \n 10 \n 20 line 20\n 21 line 21\n 22 \n 23 \n 24 line 24\n 25 \n 26 line 26\n 27 \n 28 \n 29 \n 30 line 30\n");
+}
+
+#[test]
#[cfg_attr(any(not(feature = "git"), target_os = "windows"), ignore)]
fn short_help() {
test_help("-h", "../doc/short-help.txt");