diff options
author | Rob Landley <rob@landley.net> | 2014-10-29 18:44:33 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2014-10-29 18:44:33 -0500 |
commit | 448c874348e3426be99a52c8a8c284cd35ac43b1 (patch) | |
tree | e5dc18e1da9816bd317daf919aac640f54364456 /tests | |
parent | 77503047d6071e8263f915f29503ff6cf060499f (diff) | |
download | toybox-448c874348e3426be99a52c8a8c284cd35ac43b1.tar.gz |
First batch of sed tests.
Only good for TEST_HOST=1 at the moment because the test infrastructure itself
depends on sed, so if an unfinished sed is in the $PATH it goes boing. But
hey, corner cases!
I have... more.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/sed.test | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/sed.test b/tests/sed.test new file mode 100644 index 00000000..8b008bf7 --- /dev/null +++ b/tests/sed.test @@ -0,0 +1,28 @@ +#!/bin/echo Run scripts/test.sh + +#testing "name" "command" "result" "infile" "stdin" + +# Exploring the wonders of sed addressing modes +testing '' 'sed -n 1p' "one\n" "" "one\ntwo\nthree" +testing '' 'sed 2p' "one\ntwo\ntwo\nthree" "" "one\ntwo\nthree" +testing '' 'sed -n 2p' "two\n" "" "one\ntwo\nthree" +# Fun with newlines! +testing '' 'sed -n 3p' "three" "" "one\ntwo\nthree" +testing 'sed as cat' 'sed ""' "one\ntwo\nthree" "" "one\ntwo\nthree" +testing 'sed -n $p' 'sed -n \$p' "three" "" "one\ntwo\nthree" +testing 'sed as cat #2' "sed -n '1,\$p'" "one\ntwo\nthree" "" "one\ntwo\nthree" +testing '' 'sed -n 1,2p' "one\ntwo\n" "" "one\ntwo\nthree" +testing '' 'sed -n 2,3p' "two\nthree" "" "one\ntwo\nthree" +testing '' 'sed -n 2,1p' "two\n" "" "one\ntwo\nthree" +testing 'sed -n $p (2 input)' 'sed -n \$p - input' "four\n" "four\n" \ + "one\ntwo\nthree" +# More fun with newlines! The missing \n is now _back_ +testing 'prodigal newline' "sed -n '1,\$p' - input" "one\ntwo\nthree\nfour\n" \ + "four\n" "one\ntwo\nthree" + +testing 'sed 3p - input' "sed -n 3p" "three" "four\n" "one\ntwo\nthree" + +testing 'sed match \t tab' "sed -n '/\t/p'" "\tx\n" "" "\tx\n" +testing 'sed match t delim disables \t tab' "sed -n '\t\txtp'" "" "" "\tx\n" +testing 'sed match t delim makes \t literal t' \ + "sed -n '\t\txtp'" "tx\n" "" "tx\n" |