Skip to content

Instantly share code, notes, and snippets.

@safehammad
Created December 20, 2012 20:33
Show Gist options
  • Save safehammad/4348322 to your computer and use it in GitHub Desktop.
Save safehammad/4348322 to your computer and use it in GitHub Desktop.
Tennis Score Python Script Tester
#!/bin/bash
# Tennis Score Python Script Tester
#
# Usage: tennis <python_script>
#
# Args passed to script: <score_player_1> <score_player_2> <next_point_won_by>
# New score expected: <score_player_1> <score_player_2>
#
# Where <score_player_n> is one of 0, 15, 30, 40, ADV, WIN
# And <next_point_won_by> is one of 1, 2
input=( "0 0 1" "0 0 2" "15 0 1" "15 15 2" "40 30 1" "40 30 1" "40 30 2" "40 40 1" "ADV 40 1" "ADV 40 2")
output=("15 0" "0 15" "30 0" "15 30" "WIN 30" "WIN 30" "40 40" "ADV 40" "WIN 40" "40 40")
echo
for i in ${!input[*]}; do
echo $ python $1 ${input[i]}
result=$(python $1 ${input[i]})
echo $result
if [[ $result == ${output[i]} ]]; then
echo -e "\e[00;32m********** PASS *************\e[00m"
else
echo -e "\e[00;31m********** FAIL *************\e[00m"
fi
echo
sleep 0.75
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment