/* vec-test.c test routines for the vector package. * (C) Copyright 1999 by John Halleck * All rights reserved. */ /* Version of August 18th, 1999 */ #include /* Standard IO */ #include "errors.h" /* Common error codes */ #include "vec.h" /* Matrix specific stuff */ #include "vecdebug.h" /* Standard vector debugging routines. */ #include "reportframe.h" /* Standard testing frame */ #define SIZE 8 /* ========================== MAIN ========================================== */ int main (argc, argv) int argc; char argv[]; { error problem = 0; int i; /* Loop index */ double test1[SIZE], test2[SIZE], reference[SIZE]; double ref2[SIZE]; double test3[SIZE]; double dotresult; /* We do tests on parts of vectors so that we can catch the most * common fence post errors if the programs overstep their bounds */ inittests("vec"); /* ------------------------------ test veczero ------------------------------ */ newtest("veczero"); for (i=0; i<6; i++) { test1[i] = 1.0; /* Fill with an obvious non-zero. */ test2[i] = (i==0 || i==6) ? 1.0 : 0.0; } if (ERRsize != (problem = veczero (0, test1))) goterrorstat ("bad size accepted?", problem); if (ERRnil != (problem = veczero (SIZE-2, 0)) ) goterrorstat ("nil pointer accepted?", problem); if ((problem = veczero (4, &test1[1]))) goterrorstat ("valid call failed?", problem); if ((problem == veciseq (6, test1, test2))) { goterror ("incorrect fillin?"); vecprint ("Result vector", SIZE, test1); vecprint ("Should be", SIZE, test2); } endtest(); /* ========================================================================== */ newsection ("Data Movement"); /* --------------------------- test veccpy ---------------------------------- */ newtest("veccpy"); if (ERRsize != (problem = veccpy (0, test1, test2)) ) goterrorstat ("bad size accepted?", problem); if (ERRnil != (problem = veccpy (SIZE, 0, test2)) ||ERRnil != (problem = veccpy (4, test1, 0)) ) goterrorstat ("nil pointer accepted?", problem); for (i=1;i