-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathtestreplace
executable file
·56 lines (49 loc) · 1.69 KB
/
testreplace
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
51
52
53
54
55
56
#!/bin/bash
#---------------------------------------------------------------------
# testreplace
# Author: Bob Dondero
#---------------------------------------------------------------------
#---------------------------------------------------------------------
# testreplace is a testing script for the replace program.
# To run it, issue the command "./testreplace"
#
# To use it, the working directory must contain:
# (1) replace, the executable version of your program, and
# (2) samplereplace, the given executable binary file.
# The script executes replace and samplereplace on each file
# in the working directory that ends with ".txt" with a variety of
# "from" and "to" strings, and compares the results.
#---------------------------------------------------------------------
# Validate the argument.
if [ "$#" -gt "0" ]; then
echo "Usage: testreplace"
exit 1
fi
# Call testreplacediff using file 01empty.txt and a variety of
# "from" and "to" strings.
file=01empty.txt
./testreplacediff $file 123 xyz
./testreplacediff $file "" xyz
./testreplacediff $file 123 ""
./testreplacediff $file "" ""
# Execute testreplacediff using file 02data.txt and a variety of
# "from" and "to" strings.
file=02data.txt
for fromStr in "" "1" "11" "111" "1111" "2" "123" "12" "1122" \
"111222" "11112222"
do
for toStr in "" "x" "y" "xyz" "1" "11" "111" "1111"
do
./testreplacediff "$file" "$fromStr" "$toStr"
done
done
# Execute testreplacediff using file 02data.txt and a variety of
# "from" and "to" strings.
file=03allones.txt
for fromStr in "" "1" "11" "111" "1111"
do
for toStr in "" "x" "y" "xyz" "1" "11" "111" "1111"
do
./testreplacediff "$file" "$fromStr" "$toStr"
done
done