-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest04.sh
More file actions
executable file
·26 lines (21 loc) · 794 Bytes
/
test04.sh
File metadata and controls
executable file
·26 lines (21 loc) · 794 Bytes
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
#!/bin/dash
# -n command line option
failed() { echo "$0: $@" && exit 1; }
passed() { echo "all tests passed" && exit 0; }
out=$(seq 10 40 | ./speed.pl -n ' /.[02468]/ p ')
exp=$(seq 10 40 | 2041 speed -n ' /.[02468]/ p ')
test "$out" = "$exp" || failed "test 1 failed: incorrect output: expected '$exp', got '$out'"
echo "test 1 passed"
out=$(cat speed.pl | ./speed.pl -n ' /print/ p ')
exp=$(cat speed.pl | 2041 speed -n ' /print/ p ')
test "$out" = "$exp" || failed "test 2 failed: incorrect output: expected '$exp', got '$out'"
echo "test 2 passed"
out=$(echo "hello
world
!" | ./speed.pl -n ' /^h/ p ')
exp=$(echo "hello
world
!" | 2041 speed -n ' /^h/ p ')
test "$out" = "$exp" || failed "test 3 failed: incorrect output: expected '$exp', got '$out'"
echo "test 3 passed"
passed