From 42726af60eeb4a5f06f12526f7b7e8ec4a35cbe4 Mon Sep 17 00:00:00 2001 From: Lucas K Date: Wed, 23 Dec 2020 11:03:47 -0800 Subject: [PATCH] changed tests to quit when they fail --- test.bash | 3 +-- test2.bash | 12 +++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/test.bash b/test.bash index 243d099..841e28f 100644 --- a/test.bash +++ b/test.bash @@ -17,7 +17,6 @@ sleep 1;a=$(stdbuf -oL ./randominputPauli $numqubits $numTgates > inputfullPauli b=$(stdbuf -oL ./multipauli < inputfullPauli.txt | tail -n1) are=$(echo "$a" | cut -f 1 -d " " | cut -c 1-5); aim=$(echo "$a" | cut -f 3 -d " " | cut -c 1-5); aimsign=$(echo $a | cut -f 2 -d " "); bimsign=$(echo $b | cut -f 2 -d " "); -echo $aimsign; bre=$(echo "$b" | cut -f 1 -d " " | cut -c 1-5); bim=$(echo "$b" | cut -f 3 -d " " | cut -c 1-5); echo "$i: $are $aimsign $aim and $bre $bimsign $bim" if [ "$are" == "$bre" ] && [ "$aim" == "$bim" ] && [ "$aimsign" == "$bimsign" ] @@ -25,7 +24,7 @@ then continue else echo "NOT EQUAL!" -break +exit fi done echo "Test passed!" diff --git a/test2.bash b/test2.bash index 281422b..e6b3122 100644 --- a/test2.bash +++ b/test2.bash @@ -31,12 +31,18 @@ bre=$(echo "$b" | cut -f 1 -d " " | cut -c 1-5); bim=$(echo "$b" | cut -f 3 -d " " | cut -c 1-5); echo "$i: $are $aimsign $aim and $bre $bimsign $bim" rediff=$( printf 'sqrt((%f - %f)^2)\n' "$are" "$bre" | bc -l ) imdiff=$( printf 'sqrt((%f - %f)^2)\n' "$aim" "$bim" | bc -l ) -if (( $(echo "$rediff < $threshold" |bc -l) )) && (( $(echo "$imdiff < $threshold" |bc -l) )) && [ "$aimsign" == "$bimsign" ] +if (( $(echo "$rediff < $threshold" |bc -l) )) && (( $(echo "$imdiff < $threshold" |bc -l) )) then - continue + if (( $(echo "$bim < $threshold" |bc -l) )) || [ "$aimsign" == "$bimsign" ] + then + continue + else + echo "NOTE EQUAL!" + exit + fi else echo "NOT EQUAL!" - break + exit fi done echo "Test passed!" -- 2.30.2