forked from kaime/dick
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·117 lines (97 loc) · 2.13 KB
/
test.sh
File metadata and controls
executable file
·117 lines (97 loc) · 2.13 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
# http://www.cyberciti.biz/tips/how-do-i-find-out-what-shell-im-using.html
SHELL=`ps -hp $$ | awk '{print $5}'`
ok() {
echo -e " \e[32m√\e[0m"
}
fail() {
echo -e " \e[31mFail!\e[0m"
echo "$1"
}
test_output() {
COMMAND="dick"
if [[ "$1" != "" ]]; then
COMMAND="$COMMAND $1"
fi
DICK="`dick $1`"
EXPECTED="$2"
echo -ne " - '\e[1m$COMMAND\e[0m' should output '\e[1m$EXPECTED\e[0m'"
if [[ "$?" != 0 ]]; then
fail "'$COMMAND' exit status was $?."
exit 1
fi
if [[ $DICK != $EXPECTED ]]; then
fail "Expected '$2', but got '$DICK'."
exit 1
fi
ok
}
test_fails() {
COMMAND="dick $1"
echo -ne " - '\e[1m$COMMAND\e[0m' should fail"
$COMMAND > /dev/null
if [[ $? == "0" ]]; then
fail "$COMMAND should have failed, but it didn't."
exit 1
fi
ok
}
echo -e "Testing \e[1mdick\e[0m with \e[1m$SHELL\e[0m"
test_output "" "8=====D"
test_output "10" "8==========D"
test_output "1" "8=D"
test_output "--length=2 -s" "8==D ~~~"
test_output "-l 2 -s=1" "8==D ~"
test_output "4 -s 1" "8====D ~"
test_output "-l --sperm=5" "8=====D ~~~~~"
test_output "12 -s 10" "8============D ~~~~~~~~~~"
test_output "-l 12 --sperm 0" "8============D"
test_output "-v" "dick 0.2.0"
test_output "--version" "dick 0.2.0"
test_output "-b" "
____
/ \__________
\___ | _\
/ ______|___/
\____/
"
test_output "-l 15 -b" "
____
/ \____________________
\___ | _\
/ ________________|___/
\____/
"
test_output "-s 3 -b" "
____
/ \__________
\___ | _\ _ _ _
/ ______|___/
\____/
"
test_output "-b -l 10 -s" "
____
/ \_______________
\___ | _\ _ _ _
/ ___________|___/
\____/
"
test_fails '-p'
test_fails '-q'
test_fails '--length --s'
test_fails '--l'
test_fails '--len'
test_fails '0'
test_fails 'bar'
test_fails '-l 0'
test_fails '-l none'
test_fails '--length=0'
test_fails '--length 00'
test_fails '--length -1'
test_fails '--length "0.1"'
test_fails '--length ".01"'
test_fails '--length -2.76'
test_fails '-s -1'
test_fails '--sperm 1.2'
test_fails '--sperm=0.7'
test_fails '--sperm=foo'