/[grep]/grep/tests/foad1.sh
ViewVC logotype

Diff of /grep/tests/foad1.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by julianfoad, Tue Apr 12 17:43:54 2005 UTC revision 1.3 by julianfoad, Wed Apr 27 18:30:29 2005 UTC
# Line 7  Line 7 
7  VERBOSE=  # empty or "1"  VERBOSE=  # empty or "1"
8  failures=0  failures=0
9    
10  # grep_test INPUT EXPECTED_OUTPUT PATTERN [OPTION...]  # grep_test INPUT EXPECTED_OUTPUT PATTERN_AND_OPTIONS...
11  # Run "grep" with the given INPUT, PATTERN and OPTIONs, and check that  # Run "grep" with the given INPUT, pattern and options, and check that
12  # the output is EXPECTED_OUTPUT.  If not, print a message and set 'failures'.  # the output is EXPECTED_OUTPUT.  If not, print a message and set 'failures'.
13  # "/" represents a newline within INPUT and EXPECTED_OUTPUT.  # "/" represents a newline within INPUT and EXPECTED_OUTPUT.
14  grep_test ()  grep_test ()
15  {  {
16    INPUT="$1"    INPUT="$1"
17    EXPECT="$2"    EXPECT="$2"
18    PATTERN="$3"    shift 2
19    shift 3    OUTPUT=`echo -n "$INPUT" | tr "/" "\n" | "$GREP" "$@" | tr "\n" "/"`
   OUTPUT=`echo -n "$INPUT" | tr "/" "\n" | "$GREP" "$@" "$PATTERN" | tr "\n" "/"`  
20    if test "$OUTPUT" != "$EXPECT" || test "$VERBOSE" == "1"; then    if test "$OUTPUT" != "$EXPECT" || test "$VERBOSE" == "1"; then
21      echo "Testing:  $GREP $@ \"$PATTERN\""      echo "Testing:  $GREP $@"
22      echo "  input:  \"$INPUT\""      echo "  input:  \"$INPUT\""
23      echo "  output: \"$OUTPUT\""      echo "  output: \"$OUTPUT\""
24    fi    fi
# Line 61  grep_test "4/04/"  "4/04/"  "4$"  -m1 -A Line 60  grep_test "4/04/"  "4/04/"  "4$"  -m1 -A
60  grep_test "4/444/" "4/444/" "4$"  -m1 -A99  grep_test "4/444/" "4/444/" "4$"  -m1 -A99
61    
62    
63    # Test for "-F -w" bugs.  Thanks to Gordon Lack for these two.
64    grep_test "A/CX/B/C/" "A/B/C/" -wF -e A -e B -e C
65    grep_test "LIN7C 55327/" "" -wF -e 5327 -e 5532
66    
67    
68  exit $failures  exit $failures

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26