Revision: 4471
Author: jprantan
Date: Thu Dec 9 04:12:42 2010
Log: Added tests to grep. Issue 730.
http://code.google.com/p/robotframework/source/detail?r=4471
Added:
/trunk/atest/robot/standard_libraries/deprecated_builtin/grep.txt
/trunk/atest/testdata/standard_libraries/deprecated_builtin/grep.txt
=======================================
--- /dev/null
+++ /trunk/atest/robot/standard_libraries/deprecated_builtin/grep.txt Thu
Dec 9 04:12:42 2010
@@ -0,0 +1,23 @@
+*** Settings ***
+Suite Setup Run Tests ${EMPTY}
standard_libraries/deprecated_builtin/grep.txt
+Force Tags regression jybot pybot
+Resource atest_resource.txt
+
+*** Test Cases ***
+Grep Literal
+ Check Test Case Grep Literal
+
+Grep Case Insensitive
+ Check Test Case Grep Case Insensitive
+
+Grep Simple Pattern
+ Check Test Case Grep Simple Pattern
+
+Grep Regexp
+ Check Test Case Grep Regexp
+
+No Deprecation Warning Is Shown When Grep Is Used
+ Length Should Be ${ERRORS.msgs} 0
+
+Regexp Escape
+ Check Test Case Regexp Escape
=======================================
--- /dev/null
+++ /trunk/atest/testdata/standard_libraries/deprecated_builtin/grep.txt
Thu Dec 9 04:12:42 2010
@@ -0,0 +1,43 @@
+*** Variables ***
+${TEXT} foo\nbar\nfoo bar\nFoo
+
+*** Test Cases ***
+Grep Literal
+ :FOR ${pattern} ${type} ${exp} IN foo ${EMPTY} foo\nfoo bar
+ ... o b ${EMPTY} foo bar Foo not matching any predefined type
Foo ${EMPTY}
+ ... ${EMPTY} ${TEXT} Should Match ${EMPTY} ${EMPTY}
+ \ Verify grep ${pattern} ${type} ${exp}
+
+Grep Case Insensitive
+ :FOR ${pattern} ${type} ${exp} IN foo case insensitive foo\nfoo
bar\nFoo
+ ... BAR this is CASE InsensitivE bar\nfoo bar ${EMPTY} case
insensitive ${TEXT} Should Match
+ ... case insensitive ${EMPTY}
+ \ Verify grep ${pattern} ${type} ${exp}
+
+Grep Simple Pattern
+ :FOR ${pattern} ${type} ${exp} IN foo* Simple Pattern foo\nfoo
bar
+ ... * glob ${TEXT} ${EMPTY} glob ${TEXT} Should Match
+ ... glob ${EMPTY}
+ \ Verify grep ${pattern} ${type} ${exp}
+
+Grep Regexp
+ :FOR ${pattern} ${type} ${exp} IN foo|bar regexp foo\nbar\nfoo
bar
+ ... (?i)foo|bar regexp foo\nbar\nfoo bar\nFoo [a-f]o*|b[a-r]*
regular expression foo\nbar\nfoo bar ${EMPTY}
+ ... regexp ${TEXT} Should Match regular expression ${EMPTY}
+ \ Verify grep ${pattern} ${type} ${exp}
+
+Regexp Escape
+ ${escaped} = Regexp Escape f$o^o$b[a]r()?\\
+ Should Be Equal ${escaped} f\\$o\\^o\\$b\\[a\\]r\\(\\)\\?\\\\
+ Should Match Regexp f$o^o$b[a]r()?\\ ${escaped}
+ @{patterns} = Create List $ ^ $ [ ] so%me&te[]?*x*t
+ @{escaped} = Regexp Escape @{patterns}
+ Should Be True @{escaped} ==
['\\$', '\\^', '\\$', '\\[', '\\]', 'so\\%me\\&te\\[\\]\\?\\*x\\*t']
+
+
+*** Keywords ***
+Verify Grep
+ [Arguments] ${pattern} ${pattern_type} ${exp_result}
${grep_text}=${TEXT}
+ ${res} = Grep ${grep_text} ${pattern} ${pattern_type}
+ Should Be Equal ${res} ${exp_result}
+