1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#! /bin/bash
cat > gp.dat <<EOF
Hello, World!
Goodbye, World?
EOF
grep_slice() {
./drive_grep_proc "$1" "$2" | ./slicer "$2"
}
grep_capture() {
./drive_grep_proc "$1" "$2" 1>/dev/null
}
run_test grep_slice 'Hello' gp.dat
check_output "grep_proc didn't find the right match?" <<EOF
Hello
EOF
run_test grep_slice '.*' gp.dat
check_output "grep_proc didn't find all lines?" < gp.dat
run_test grep_slice '\w+,' gp.dat
check_output "grep_proc didn't find the right matches?" <<EOF
Hello,
Goodbye,
EOF
run_test grep_slice '\w+.' gp.dat
check_output "grep_proc didn't find multiple matches?" <<EOF
Hello,
World!
Goodbye,
World?
EOF
run_test grep_capture '(\w+), World' gp.dat
check_error_output "grep_proc didn't capture matches?" <<EOF
0(0:5)Hello
1(0:7)Goodbye
EOF
check_output "grep_proc didn't capture matches?" <<EOF
EOF
|