Skip to content

Instantly share code, notes, and snippets.

@mengcz13
Last active October 19, 2021 23:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mengcz13/817e681f7834c34175b6b66dbd6dc2fc to your computer and use it in GitHub Desktop.
Save mengcz13/817e681f7834c34175b6b66dbd6dc2fc to your computer and use it in GitHub Desktop.
cs103l_fall21_lab5test
COLOR='\033[0;32m'
NC='\033[0m' # No Color
printf '6\ncs103 trojan\nmidterm\naced\nperfect\nscore\n' > wordbank.txt
echo -e "${COLOR}-----use the provided wordbank file, allowing demo of correct guess (30 points)-----${NC}"
sed -i "s/int target = rand() % numWords;/int target = numWords - 1;/" scramble.cpp
g++ scramble.cpp -o scramble
./scramble wordbank.txt <<< "score"
echo ""
echo -e "${COLOR}-----allow TA/CP to create a wordbank containing 2 words, allowing demo of correct guess (20 points)-----${NC}"
printf "2\nsupercalifragilisticexpialidocious pseudohypoparathyroidism" >> ta_wordbank.txt
./scramble ta_wordbank.txt <<< "pseudohypoparathyroidism"
rm ta_wordbank.txt
echo ""
echo -e "${COLOR}-----demonstrate the correct handling of an input filename that DOES NOT exist (10 points - no partial credit)-----${NC}"
./scramble utopia.txt
echo ""
echo -e "${COLOR}-----demonstrate the correct handling of an input wordbank that DOES NOT contain a number (10 points - no partial credit)-----${NC}"
printf "supercalifragilisticexpialidocious pseudohypoparathyroidism" >> ta_wordbank.txt
./scramble ta_wordbank.txt <<< "pseudohypoparathyroidism"
rm ta_wordbank.txt
echo ""
echo -e "${COLOR}-----Test: memleak 1-----${NC}"
g++ memleak.cpp -o memleak
./memleak 1
valgrind --tool=memcheck --leak-check=yes ./memleak 1
echo ""
echo -e "${COLOR}-----Test: memleak 2-----${NC}"
./memleak 2 <<< "score"
valgrind --tool=memcheck --leak-check=yes ./memleak 2 <<< "score"
echo ""
echo -e "${COLOR}-----Test: scramble-----${NC}"
valgrind --tool=memcheck --leak-check=yes ./scramble wordbank.txt <<< "score"
echo ""
rm scramble
sed -i "s/int target = numWords - 1;/int target = rand() % numWords;/" scramble.cpp
rm memleak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment