User:MaintenanceRequired/Scripts/Shell scripts/Testing

= allTestsPassed=true mkdir "tests"
 * 1) !/bin/sh

for t in {1..100} do shuf -i 1-100 -n $(($RANDOM % 31)) > tests/$t done
 * 1) creates 100 files with random numbers from 1-100. No. of lines are randomised.

for s in {1..100} do sort -n < tests/$s > tests/$s.expected ./useIntList < tests/$s > tests/$s.observed diff tests/$s.expected tests/$s.observed > /dev/null if [ $? -eq 0 ] then echo "test $s .. passed" else echo "test $s .. failed" sdiff tests/$s.expected tests/$s.observed $allTestsPassed = false fi done
 * 1) compare loop.

if $allTestsPassed; then echo "All tests passed! You are awesome :-)" fi

rm -rf "tests"
 * 1) cleans directory.

Documentation

 * Bash/Shell script for automated testing. Creates 100 files with random numbers in it (assumption: at least 1 number) and sorts it in ascending order.
 * ./useIntList is written in C.