ip link: add VLAN support
[oweals/busybox.git] / testsuite / sed.tests
index 61551e31ce8fc551ac2d5263e10ccbc527e10f4d..468565f47081280e9007d6ee80cc5687547900d1 100755 (executable)
@@ -2,11 +2,11 @@
 
 # SUSv3 compliant sed tests.
 # Copyright 2005 by Rob Landley <rob@landley.net>
-# Licensed under GPL v2, see file LICENSE for details.
+# Licensed under GPLv2, see file LICENSE in this source tree.
 
 . ./testing.sh
 
-# testing "description" "arguments" "result" "infile" "stdin"
+# testing "description" "commands" "result" "infile" "stdin"
 
 # Corner cases
 testing "sed no files (stdin)" 'sed ""' "hello\n" "" "hello\n"
@@ -48,13 +48,12 @@ testing "sed accepts multiple -e" "sed -e 'i\' -e '1' -e 'a\' -e '3'" \
 
 # substitutions
 testing "sed -n" "sed -n -e s/foo/bar/ -e s/bar/baz/" "" "" "foo\n"
+testing "sed with empty match" "sed 's/z*//g'" "string\n" "" "string\n"
 testing "sed s//p" "sed -e s/foo/bar/p -e s/bar/baz/p" "bar\nbaz\nbaz\n" \
        "" "foo\n"
 testing "sed -n s//p" "sed -ne s/abc/def/p" "def\n" "" "abc\n"
-test x"$SKIP_KNOWN_BUGS" = x"" && {
 testing "sed s//g (exhaustive)" "sed -e 's/[[:space:]]*/,/g'" ",1,2,3,4,5,\n" \
        "" "12345\n"
-}
 testing "sed s arbitrary delimiter" "sed -e 's woo boing '" "boing\n" "" "woo\n"
 testing "sed s chains" "sed -e s/foo/bar/ -e s/bar/baz/" "baz\n" "" "foo\n"
 testing "sed s chains2" "sed -e s/foo/bar/ -e s/baz/nee/" "bar\n" "" "foo\n"
@@ -225,7 +224,7 @@ testing "sed s/xxx/[/" "sed -e 's/xxx/[/'" "[\n" "" "xxx\n"
 #testing "sed -g (exhaustive)" "sed -e 's/[[:space:]]*/,/g'" ",1,2,3,4,5," \
 #      "" "12345"
 
-# testing "description" "arguments" "result" "infile" "stdin"
+# testing "description" "commands" "result" "infile" "stdin"
 
 testing "sed n command must reset 'substituted' bit" \
        "sed 's/1/x/;T;n;: next;s/3/y/;t quit;n;b next;: quit;q'" \
@@ -287,7 +286,30 @@ testing "sed -i with address modifies all files, not only first" \
        "cp input input2; sed -i -e '1s/foo/bar/' input input2 && cat input input2; rm input2" \
        "bar\nbar\n" "foo\n" ""
 
+testing "sed understands \r" \
+       "sed 's/r/\r/'" \
+       "\rrr\n" "" "rrr\n"
+
+testing "sed -i finishes ranges correctly" \
+       "sed '1,2d' -i input; echo \$?; cat input" \
+       "0\n3\n4\n" "1\n2\n3\n4\n" ""
+
+testing "sed zero chars match/replace advances correctly 1" \
+       "sed 's/l*/@/g'" \
+       "@h@e@o@\n" "" "helllo\n"
+
+testing "sed zero chars match/replace advances correctly 2" \
+       "sed 's [^ .]* x g'" \
+       "x x.x\n" "" " a.b\n"
+
+testing "sed zero chars match/replace logic must not falsely trigger here 1" \
+       "sed 's/a/A/g'" \
+       "_AAA1AA\n" "" "_aaa1aa\n"
+
+testing "sed zero chars match/replace logic must not falsely trigger here 2" \
+       "sed 's/ *$/_/g'" \
+       "qwerty_\n" "" "qwerty\n"
 
-# testing "description" "arguments" "result" "infile" "stdin"
+# testing "description" "commands" "result" "infile" "stdin"
 
 exit $FAILCOUNT