blob: 1c7fa9bcfd90d8dfe7b8cc6576e13dc0c7655806 (
plain)
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
|
#!/bin/sh
if [ $# -lt 1 ]; then
echo "Usage $0 test_number [start] [end]"
exit
fi
if [ $1 = "--error" ]; then
echo -n "No arguments: "
if [ $(./checker)="" ]; then
echo -n "\033[32m[OK]\033[0m "
else
echo -n "\033[32m[KO]\033[0m "
fi
if [ $(./push_swap)="" ]; then
echo "\033[32m[OK]\033[0m"
else
echo "\033[32m[KO]\033[0m"
fi
echo -n "Not digit character "
if [ ! $(./checker 1 2 3 four)="Error\n" ]; then
echo -n "\033[32m[OK]\033[0m "
else
echo -n "\033[32m[KO]\033[0m "
fi
if [ ! $(./checker -1 2 3-3)="Error\n" ]; then
echo -n "\033[32m[OK]\033[0m "
else
echo -n "\033[32m[KO]\033[0m "
fi
if [ ! $(./checker 1_000 23 0 -1)="Error\n" ]; then
echo -n "\033[32m[OK]\033[0m "
else
echo -n "\033[32m[KO]\033[0m "
fi
exit
fi
test_nb=$1
if [ -z $2 ]; then
start=1
else
start=$2
fi
if [ -z $3 ]; then
end=100
else
end=$3
fi
for i in $(seq 1 $test_nb); do
arg=$(./random_stack.rb $start $end)
echo $arg
result=$(./push_swap $arg | ./checker $arg)
case $result in
OK)
echo -n "\033[32m.\033[0m"
;;
KO)
echo -n "\033[31m!\033[0m"
echo "Test $i failed with: $arg" >> result.log
;;
Error)
echo -n "\033[31m!\033[0m"
echo "Test $i failed due to parsing error with: $arg" >> result.log
;;
*)
echo "Unexpected output"
exit
;;
esac
done
|