From: Sylvestre Ledru <[email protected]>

* tests/csplit/csplit-suppress-matched.pl (@csplit_tests): Add test
cases where --suppress-matched gets a line number one past the end
of input, alone, repeated, and after its previous line was already
suppressed.
https://github.com/uutils/coreutils/pull/15637

Link: https://github.com/coreutils/coreutils/pull/394
---
 tests/csplit/csplit-suppress-matched.pl | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/tests/csplit/csplit-suppress-matched.pl 
b/tests/csplit/csplit-suppress-matched.pl
index ecb00a0c7..9e16bd3de 100755
--- a/tests/csplit/csplit-suppress-matched.pl
+++ b/tests/csplit/csplit-suppress-matched.pl
@@ -130,6 +130,22 @@ my @csplit_tests =
   # ... and elide-empty removes just that trailing split.
   ["mixed-2", '--suppress-matched -zq - 3 /^6$/', {IN_PIPE => $IN_SEQ_6},
     {OUTPUTS => [ "1\n2\n", "4\n5\n" ]}],
+
+  # A line number one past the end: there is no line to suppress,
+  # so the split is complete.
+  ["past-end-1", '--suppress-matched -q - 7', {IN_PIPE => $IN_SEQ_6},
+    {OUTPUTS => [ "1\n2\n3\n4\n5\n6\n", "" ]}],
+  ["past-end-2", "--suppress-matched -q - 3 '{1}'",
+    {IN_PIPE => "1\n2\n3\n4\n5\n"},
+    {OUTPUTS => [ "1\n2\n", "4\n5\n", "" ]}],
+  ["past-end-3", "-k --suppress-matched -q - 3 '{*}'",
+    {IN_PIPE => "1\n2\n3\n4\n5\n"},
+    {OUTPUTS => [ "1\n2\n", "4\n5\n", "" ]}, {EXIT => 1},
+    {ERR => "$prog: '3': line number out of range on repetition 2\n"}],
+  # Line 6 was already suppressed, so nothing is left for line 7.
+  ["past-end-4", '--suppress-matched -q - 6 7', {IN_PIPE => $IN_SEQ_6},
+    {OUTPUTS => [ ]}, {EXIT => 1},
+    {ERR => "$prog: '7': line number out of range\n"}],
 );
 
 
-- 
2.55.0


Reply via email to