/* File: t_insertion.c Test the Insertion Sort routines */ #include #include "sorting.h" main(int argc, char *argv[]) { data *A ; index i, n ; if (argc != 2) { fprintf(stderr, "Usage: t_insertion filename\n") ; exit(1) ; } n = readarray(argv[1], &A) ; if ( n <= 0 ) { fprintf(stderr, "oops, can't read\n" ) ; exit(1) ; } insertion_sort(A,0,n-1) ; #ifndef NDEBUG if (!checkarray(A,n)) { printf("Sorting routine INCORRECT!\n") ; } printarray(A,n) ; #endif }