From 5a5847e7eec00048c9f94de20e46ab6cdfeea2a3 Mon Sep 17 00:00:00 2001 From: djonker Date: Wed, 1 Mar 2023 17:42:12 +0100 Subject: [PATCH] something --- test.sh | 106 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/test.sh b/test.sh index 1950cfb..da36499 100755 --- a/test.sh +++ b/test.sh @@ -28,7 +28,7 @@ checkfile() if [ $? -ne $2 ] then printf "\e[1;31mMakefile does not create $1\e[0;00m\n" - rm -rf tests/files + rm -rf tmp exit 1 fi } @@ -116,7 +116,7 @@ countsilently() pushswap() { - ./push_swap $2 > tests/files/output 2>&1 + ./push_swap $2 > tmp/output 2>&1 if [ $? -eq $1 ] then printf "\e[1;32mReturn value OK\e[0;00m\n" @@ -128,7 +128,7 @@ pushswap() checker() { - ./push_swap $2 | $CHECKER $2 > tests/files/output 2>&1 + ./push_swap $2 | $CHECKER $2 > tmp/output 2>&1 if [ $? -eq $1 ] then printf "\e[1;32mReturn value OK\e[0;00m\n" @@ -140,7 +140,7 @@ checker() onlychecker() { - $CHECKER $2 > tests/files/output 2>&1 + $CHECKER $2 > tmp/output 2>&1 if [ $? -eq $1 ] then printf "\e[1;32mReturn value OK\e[0;00m\n" @@ -152,7 +152,7 @@ onlychecker() checkersilent() { - ./push_swap $2 | $CHECKER $2 > tests/files/output 2>&1 + ./push_swap $2 | $CHECKER $2 > tmp/output 2>&1 if [ $? -ne $1 ] then printf "\e[1;31mBad Return Value\e[0;00m\n" @@ -162,7 +162,7 @@ checkersilent() checkoutput() { - diff tests/files/output $1 > /dev/null 2>&1 + diff tmp/output $1 > /dev/null 2>&1 if [ $? -eq 0 ] then printf "\e[1;32mOutput OK\e[0;00m\n" @@ -174,7 +174,7 @@ checkoutput() checkoutputsilent() { - diff tests/files/output $1 > /dev/null 2>&1 + diff tmp/output $1 > /dev/null 2>&1 if [ $? -ne 0 ] then printf "\e[1;31mBad Output\e[0;00m\n" @@ -184,7 +184,7 @@ checkoutputsilent() checkoutputsupersilent() { - diff tests/files/output $1 > /dev/null 2>&1 + diff tmp/output $1 > /dev/null 2>&1 if [ $? -ne 0 ] then FAULTS=$(($FAULTS+1)) @@ -229,7 +229,7 @@ batchtester() do ARG=$(for (( i=1;i<=10000;i++ )) do echo $RANDOM $i; done | sort -k1 | cut -d' ' -f2 | head -$1 | tr '\n' ' ') checkersilent 0 "$ARG" - checkoutputsilent tests/files/ok + checkoutputsilent tmp/ok countsilently $3 $4 $5 $6 $7 "$ARG" done } @@ -240,7 +240,7 @@ batchchecker() do ARG=$(for (( i=1;i<=10000;i++ )) do echo $RANDOM $i; done | sort -k1 | cut -d' ' -f2 | head -$1 | tr '\n' ' ') checkersilent 0 "$ARG" - checkoutputsupersilent tests/files/ok + checkoutputsupersilent tmp/ok done } @@ -261,11 +261,11 @@ COUNT4=0 SLEEP=1 FAULTS=0 CHECKF=0 -mkdir -p tests/files -touch tests/files/empty -echo "Error" > tests/files/error -echo "OK" > tests/files/ok -echo "KO" > tests/files/ko +mkdir -p tmp +touch tmp/empty +echo "Error" > tmp/error +echo "OK" > tmp/ok +echo "KO" > tmp/ko if [ $2 ] then if [ $1 -eq 100 ] @@ -274,7 +274,7 @@ then make > /dev/null batchtester 100 $2 700 900 1100 1300 1500 printresult 700 900 1100 1300 1500 - rm -rf tests/files + rm -rf tmp exit 0 elif [ $1 -eq 500 ] then @@ -282,11 +282,11 @@ then make > /dev/null batchtester 500 $2 5500 7000 8500 10000 11500 printresult 5500 7000 8500 10000 11500 - rm -rf tests/files + rm -rf tmp exit 0 else printf "\e[1;31mRun the test in one of the following ways\n./test\n./test.sh [SLEEPTIME]\n./test 100 [ITERATIONS]\n./test 500 [ITERATIONS]\e[0;00m\n" - rm -rf tests/files + rm -rf tmp exit 1 fi fi @@ -345,74 +345,74 @@ sleep $SLEEP # Test 4 printf "\e[1;36mTest 4 Running push_swap with non numeric value\e[0;00m\n" pushswap 1 "a" -checkoutput tests/files/error +checkoutput tmp/error sleep $SLEEP # Test 5 printf "\e[1;36mTest 5 Running push_swap with hidden non numeric value begin\e[0;00m\n" pushswap 1 "a1234" -checkoutput tests/files/error +checkoutput tmp/error sleep $SLEEP # Test 6 printf "\e[1;36mTest 6 Running push_swap with hidden non numeric value middle\e[0;00m\n" pushswap 1 "12/34" -checkoutput tests/files/error +checkoutput tmp/error sleep $SLEEP # Test 7 printf "\e[1;36mTest 7 Running push_swap with hidden non numeric value end\e[0;00m\n" pushswap 1 "1234-" -checkoutput tests/files/error +checkoutput tmp/error sleep $SLEEP # Test 8 printf "\e[1;36mTest 8 Running push_swap with duplicate number\e[0;00m\n" pushswap 1 "1 2 3 4 5 6 7 1" -checkoutput tests/files/error +checkoutput tmp/error sleep $SLEEP # Test 9 printf "\e[1;36mTest 9 Running push_swap with max int + 1\e[0;00m\n" pushswap 1 "1 2 3 4 5 6 7 8 9 2147483648" -checkoutput tests/files/error +checkoutput tmp/error sleep $SLEEP # Test 10 printf "\e[1;36mTest 10 Running push_swap with min int - 1\e[0;00m\n" pushswap 1 "-2147483649 1 2 3 4 5 6 7 8 9" -checkoutput tests/files/error +checkoutput tmp/error sleep $SLEEP # Test 11 printf "\e[1;36mTest 11 Running push_swap without arguments\e[0;00m\n" pushswap 0 -checkoutput tests/files/empty +checkoutput tmp/empty sleep $SLEEP # Test 12 printf "\e[1;36mTest 12 Running push_swap with one number\e[0;00m\n" pushswap 0 "42" -checkoutput tests/files/empty +checkoutput tmp/empty sleep $SLEEP # Test 13 printf "\e[1;36mTest 13 Running push_swap with numbers in order\e[0;00m\n" pushswap 0 "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20" -checkoutput tests/files/empty +checkoutput tmp/empty sleep $SLEEP # Test 14 printf "\e[1;36mTest 14 Running push_swap against checker with 2 1 0\e[0;00m\n" checker 0 "2 1 0" -checkoutput tests/files/ok +checkoutput tmp/ok count 2 3 3 3 3 "2 1 0" sleep $SLEEP # Test 15 printf "\e[1;36mTest 15 Running push_swap against checker with 1 5 2 4 3\e[0;00m\n" checker 0 "1 5 2 4 3" -checkoutput tests/files/ok +checkoutput tmp/ok count 7 8 9 10 12 "1 5 2 4 3" sleep $SLEEP @@ -445,12 +445,12 @@ then then printf "\e[1;35mBut we got no errors, Congratulations\e[0;00m\n" make fclean > /dev/null - rm -rf tests/files + rm -rf tmp exit 0 else printf "\e[1;31mAnd we got $FAULTS errors\nSo that's a bummer\e[0;00m\n" make fclean > /dev/null - rm -rf tests/files + rm -rf tmp exit 1 fi fi @@ -474,126 +474,126 @@ sleep $SLEEP # Test 21 printf "\e[1;36mTest 21 Running checker with non numeric value\e[0;00m\n" onlychecker 1 "a" -checkoutput tests/files/error +checkoutput tmp/error sleep $SLEEP # Test 22 printf "\e[1;36mTest 22 Running checker with hidden non numeric value begin\e[0;00m\n" onlychecker 1 "a1234" -checkoutput tests/files/error +checkoutput tmp/error sleep $SLEEP # Test 23 printf "\e[1;36mTest 23 Running checker with hidden non numeric value middle\e[0;00m\n" onlychecker 1 "12/34" -checkoutput tests/files/error +checkoutput tmp/error sleep $SLEEP # Test 24 printf "\e[1;36mTest 24 Running checker with hidden non numeric value end\e[0;00m\n" onlychecker 1 "1234-" -checkoutput tests/files/error +checkoutput tmp/error sleep $SLEEP # Test 25 printf "\e[1;36mTest 25 Running checker with duplicate number\e[0;00m\n" onlychecker 1 "1 2 3 4 5 6 7 1" -checkoutput tests/files/error +checkoutput tmp/error sleep $SLEEP # Test 26 printf "\e[1;36mTest 26 Running checker with max int + 1\e[0;00m\n" onlychecker 1 "1 2 3 4 5 6 7 8 9 2147483648" -checkoutput tests/files/error +checkoutput tmp/error sleep $SLEEP # Test 27 printf "\e[1;36mTest 27 Running checker with min int - 1\e[0;00m\n" onlychecker 1 "-2147483649 1 2 3 4 5 6 7 8 9" -checkoutput tests/files/error +checkoutput tmp/error sleep $SLEEP # Test 28 printf "\e[1;36mTest 28 Running checker without arguments\e[0;00m\n" onlychecker 0 -checkoutput tests/files/empty +checkoutput tmp/empty sleep $SLEEP # Test 29 printf "\e[1;36mTest 29 Running checker with no stdin\e[0;00m\n" printf "Please press CTRL+D (maybe twice)\n" onlychecker 0 "42" -checkoutput tests/files/ok +checkoutput tmp/ok sleep $SLEEP # Test 30 printf "\e[1;36mTest 30 Running checker with all possible moves\e[0;00m\n" printf "Please type pb, pb, sa, sb, ss, ra, rb, rr, rra, rrb, rrr, pa and hit CTRL+D (maybe twice)\n" onlychecker 0 "42 21 420 210" -checkoutput tests/files/ko +checkoutput tmp/ko sleep $SLEEP # Test 31 printf "\e[1;36mTest 31 Running checker with some impossible moves\e[0;00m\n" printf "Please type pa, pb, sa, sb, ss, ra, rb, rr, rra, rrb, rrr and hit CTRL+D (maybe twice)\n" onlychecker 0 "42" -checkoutput tests/files/ok +checkoutput tmp/ok sleep $SLEEP # Test 32 printf "\e[1;36mTest 32 Running checker invalid stdin\e[0;00m\n" printf "Please type br and press enter Do Not hit CTRL+D\n" onlychecker 1 "42" -checkoutput tests/files/error +checkoutput tmp/error sleep $SLEEP # Test 33 printf "\e[1;36mTest 33 Running checker invalid stdin space before\e[0;00m\n" printf "Please type ' sa' and press enter Do Not hit CTRL+D\n" onlychecker 1 "42" -checkoutput tests/files/error +checkoutput tmp/error sleep $SLEEP # Test 34 printf "\e[1;36mTest 34 Running checker invalid stdin space after\e[0;00m\n" printf "Please type 'sa ' and press enter Do Not hit CTRL+D\n" onlychecker 1 "42" -checkoutput tests/files/error +checkoutput tmp/error sleep $SLEEP # Test 35 printf "\e[1;36mTest 35 Running checker with wrong stdin 0 9 1 8 2 7 3 6 4 5\e[0;00m\n" printf "Please type sa, pb, rrr and hit CTRL+D (maybe twice)\n" onlychecker 0 "0 9 1 8 2 7 3 6 4 5" -checkoutput tests/files/ko +checkoutput tmp/ko sleep $SLEEP # Test 36 printf "\e[1;36mTest 36 Running checker with wrong stdin 32 -65 12 83 55 23 54 53 16\e[0;00m\n" printf "Please type sa, ra, rra and hit CTRL+D (maybe twice)\n" onlychecker 0 "32 -65 12 83 55 23 54 53 16" -checkoutput tests/files/ko +checkoutput tmp/ko sleep $SLEEP # Test 37 printf "\e[1;36mTest 37 Running checker with numbers 1 - 20 in order\e[0;00m\n" printf "Please hit CTRL+D (maybe twice)\n" onlychecker 0 "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20" -checkoutput tests/files/ok +checkoutput tmp/ok sleep $SLEEP # Test 38 printf "\e[1;36mTest 38 Running checker with valid input 0 9 1 8 2\e[0;00m\n" printf "Please type pb, ra, pb, ra, sa, ra, pa, pa and hit CTRL+D (maybe twice)\n" onlychecker 0 "0 9 1 8 2" -checkoutput tests/files/ok +checkoutput tmp/ok sleep $SLEEP # Test 39 printf "\e[1;36mTest 39 Running checker with valid input a little harder\e[0;00m\n" printf "Please type rra, rra and hit CTRL+D (maybe twice)\n" onlychecker 0 "12345 23456 34567 45678 56789 67890 -98765 -87654" -checkoutput tests/files/ok +checkoutput tmp/ok sleep $SLEEP # Test 40 @@ -616,9 +616,9 @@ then else printf "\e[1;31mwe got $FAULTS errors\nSo that's a bummer\e[0;00m\n" make fclean > /dev/null - rm -rf tests/files + rm -rf tmp exit 1 fi make fclean > /dev/null -rm -rf tests/files +rm -rf tmp exit 0