summaryrefslogtreecommitdiff
path: root/testsuite/sed.tests
diff options
context:
space:
mode:
authorRob Landley2006-02-23 23:13:16 +0000
committerRob Landley2006-02-23 23:13:16 +0000
commit6b6edf959dfeb8cacf101b6cc7db25e8d809f633 (patch)
tree81b3f3df3f2a5bcad021747d6ea8f873222dfd24 /testsuite/sed.tests
parentb21837714a3765137bfad16e139bf7b9d6fbbcc6 (diff)
downloadbusybox-6b6edf959dfeb8cacf101b6cc7db25e8d809f633.zip
busybox-6b6edf959dfeb8cacf101b6cc7db25e8d809f633.tar.gz
Lots of tests the fix to sed needs to pass...
Diffstat (limited to 'testsuite/sed.tests')
-rwxr-xr-xtestsuite/sed.tests35
1 files changed, 35 insertions, 0 deletions
diff --git a/testsuite/sed.tests b/testsuite/sed.tests
index 479dd9a..1f22082 100755
--- a/testsuite/sed.tests
+++ b/testsuite/sed.tests
@@ -98,6 +98,41 @@ testing "sed d ends script iteration" \
testing "sed d ends script iteration (2)" \
"-e '/ook/d;a\' -e 'bang'" "woot\nbang\n" "" "ook\nwoot\n"
+# Multiple files, with varying newlines and NUL bytes
+testing "sed embedded NUL" "-e 's/woo/bang/'" "\0bang\0woo\0" "" "\0woo\0woo\0"
+
+# sed has funky behavior with newlines at the end of file. Test lots of
+# corner cases with the optional newline appending behavior.
+
+testing "sed normal newlines" "-e 's/woo/bang/' input -" "bang\nbang\n" \
+ "woo\n" "woo\n"
+testing "sed leave off trailing newline" "-e 's/woo/bang/' input -" \
+ "bang\nbang" "woo\n" "woo"
+testing "sed autoinsert newline" "-e 's/woo/bang/' input -" "bang\nbang" \
+ "woo" "woo"
+testing "sed empty file plus cat" "-e 's/nohit//' input -" "one\ntwo" \
+ "" "one\ntwo"
+testing "sed cat plus empty file" "-e 's/nohit//' input -" "one\ntwo" \
+ "one\ntwo" ""
+testing "sed append autoinserts newline" "-e '/woot/a woo' -" "woot\nwoo\n" \
+ "" "woot"
+testing "sed insert doesn't autoinsert newline" "-e '/woot/i woo' -" \
+ "woo\nwoot" "" "woot"
+testing "sed print autoinsert newlines" "-e 'p' -" "one\none" "" "one"
+testing "sed print autoinsert newlines two files" "-e 'p' input -" \
+ "one\none\ntwo\ntwo" "one" "two"
+
+testing "sed noprint, no match, no newline" "-ne 's/woo/bang/' input" \
+ "" "no\n" ""
+testing "sed selective matches with nl" "-ne 's/woo/bang/p' input -" \
+ "a bang\nc bang\n" "a woo\nb no" "c woo\nd no"
+testing "sed selective matches insert newline" "-ne 's/woo/bang/p' input -" \
+ "a bang\nb bang\nd bang" "a woo\nb woo" "c no\nd woo"
+testing "sed selective matches noinsert newline" "-ne 's/woo/bang/p' input -" \
+ "a bang\nb bang" "a woo\nb woo" "c no\nd no"
+testing "sed clusternewline" "-e '/one/a 111' -e '/two/i 222' -e p input -" \
+ "one\none\n111\n222\ntwo\ntwo" "one" "two"
+
# Ponder this a bit more, why "woo not found" from gnu version?
#testing "sed doesn't substitute in deleted line" \
# "-e '/ook/d;s/ook//;t woo;a bang;'" "bang" "" "ook\n"