Advertisement
zopper

sort test

Dec 4th, 2012
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.70 KB | None | 0 0
  1. #!/bin/bash
  2. # sort test
  3. BIN=./hello
  4.  
  5. MAXCOUNT=3 # count of tests
  6. MAX_A_SIZE=100 # max array size
  7.  
  8. count=1
  9.  
  10. while [ "$count" -le "$MAXCOUNT" ];do
  11.     echo "------------- BEGIN TEST $count --------------"
  12.  
  13.     a_size=$RANDOM;
  14.     let "a_size %= $MAX_A_SIZE"
  15.     echo "Velikost pole: $a_size"
  16.  
  17.     # generate array
  18.     array="";
  19.     i=1
  20.     while [ "$i" -le "$a_size" ];do
  21.         array=`echo -e "$array\n$RANDOM"`
  22.         let "i += 1"
  23.     done
  24.     # sort for correct order
  25.     echo -e "$array"|sort -h|grep -E '[0-9]+' > correct_file
  26.    
  27.    
  28.     # DO TEST
  29.     $BIN <<< "$a_size  $array"|grep -E '[0-9]+' > result_file
  30.  
  31.     # test result
  32.     echo "Vysledek: diff correct_file result_file"
  33.     diff correct_file result_file
  34.    
  35.     let "count += 1"
  36. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement