-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimpletesting.sh
More file actions
executable file
·43 lines (35 loc) · 999 Bytes
/
simpletesting.sh
File metadata and controls
executable file
·43 lines (35 loc) · 999 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
./simplegrep -d exampledir for > /dev/null
SIMPLEGREP=$(cat simplegrep.txt | wc -l)
ORIGINALGREP=$(grep -r for ./exampledir | wc -l)
#checking if same number of patterns found
if [ ! $SIMPLEGREP = $ORIGINALGREP ]
then
echo "different number of patterns found"
else
echo "OK; same number of patterns found"
fi
DIRRES=$(./simplegrep -d exampledir for | head -n 3)
DIRGOODRES=$'Searched files: 6\nFiles with pattern: 5\nPatterns number: 9'
if [ ! "$DIRGOODRES" = "$DIRRES" ]
then
echo "wrong output"
else
echo "OK"
fi
DIRRES=$(./simplegrep -d exampledir/anotherdir for | head -n 3)
DIRGOODRES=$'Searched files: 1\nFiles with pattern: 1\nPatterns number: 3'
if [ ! "$DIRGOODRES" = "$DIRRES" ]
then
echo "wrong output"
else
echo "OK"
fi
DIRRES=$(./simplegrep -d exampledir/seconddir for | head -n 3)
DIRGOODRES=$'Searched files: 3\nFiles with pattern: 2\nPatterns number: 3'
if [ ! "$DIRGOODRES" = "$DIRRES" ]
then
echo "wrong output"
else
echo "OK"
fi