aboutsummaryrefslogtreecommitdiff
path: root/scripts/test/grep.test
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2013-08-04 15:04:08 -0500
committerRob Landley <rob@landley.net>2013-08-04 15:04:08 -0500
commit7b72ab4c9bdcdfe08018f0e9cc6eee7d20cb415e (patch)
tree73289a2d2a9b9850f4a9fbc006bf327930551878 /scripts/test/grep.test
parentdad378bb17f1910014383bf196e87028e98d81d6 (diff)
downloadtoybox-7b72ab4c9bdcdfe08018f0e9cc6eee7d20cb415e.tar.gz
Fluff out grep test suite some more, including lots of things we don't pass yet.
Diffstat (limited to 'scripts/test/grep.test')
-rwxr-xr-xscripts/test/grep.test28
1 files changed, 27 insertions, 1 deletions
diff --git a/scripts/test/grep.test b/scripts/test/grep.test
index dde3d5c3..13b8e0bb 100755
--- a/scripts/test/grep.test
+++ b/scripts/test/grep.test
@@ -42,8 +42,34 @@ testing "grep -n" "grep -n is input" "1:this is test\n2:this is test2\n" \
"this is test\nthis is test2\ntest case" ""
testing "grep -o" "grep -o is input" "is\nis\nis\nis\n" \
"this is test\nthis is test2\ntest case" ""
-testing "grep -s" "grep -s hello asdf 2>&1" "" "" ""
+testing "grep -s" "grep -hs hello asdf input 2>&1" "hello\n" "hello\n" ""
testing "grep -v" "grep -v abc input" "1234123asdfas123123\n1ABa\n" \
"1234123asdfas123123\n1ABabc\nabc\n1ABa\nabcde" ""
testing "grep -w" "grep -w abc input" "abc\n" \
"1234123asdfas123123\n1ABabc\nabc\n1ABa\nabcde" ""
+testing "grep -x" "grep -x abc input" "abc\n" \
+ "aabcc\nabc\n" ""
+
+testing "grep -H (standard input)" "grep -H abc" "(standard input):abc\n" \
+ "" "abc\n"
+testing "grep -l (standard input)" "grep -l abc" "(standard input)\n" \
+ "" "abc\n"
+testing "grep -n two inputs" "grep -hn def - input" "2:def\n2:def\n" \
+ "abc\ndef\n" "abc\ndef\n"
+
+testing "grep pattern with newline" "grep 'abc
+def' input" "aabcc\nddeff\n" \
+ "aaaa\naabcc\n\dddd\nddeff\nffff\n" ""
+
+testing "grep -lH" "grep -lH abc input" "input\n" "abc\n" ""
+testing "grep -cn" "grep -cn abc input" "1\n" "abc\n" ""
+testing "grep -qs" "grep -qs abc none input && echo yes" "yes\n" "abc\n" ""
+testing "grep -hl" "grep -hl abc input" "input\n" "abc\n" ""
+testing "grep -b stdin" "grep -b one" "0:one\n4:one\n8:one\n" "" "one\none\none\n"
+testing "grep -o overlap" "grep -bo aaa" "1:aaa\n" "" "baaaa\n"
+testing "grep -co" "grep -co one input" "3\n" "one one one\n" ""
+testing "grep -nom" "grep -nom 2 one" "1:one\n1:one\n1:one\n2:one\n2:one\n" \
+ "" "one one one\none one\none"
+testing "grep -vo" "grep -vo one input" "twothree\n" "onetwoonethreeone\n" ""
+testing "grep no newline" "grep -h one input -" \
+ "hello one\nthere one\n" "hello one" "there one"