/* Title: Testvectors.c Author: Xiaoyang Yu Revised: 22-NOV-2002 Description: Black-Box test for any module named Vectors implementing Lab5 MIS. Module Interface Specification: INTERFACE Testvectors; END Testvectors. */ #include "stdio.h" #include "stdlib.h" #include "string.h" #include "vectors.h" /* test procedure */ void test(float x1,float y1,float x2,float y2,float r) { vector v1,v2; /* displaying the given inputs */ printf("*** testing (x1,y1,x2,y2)=(%f,%f,%f,%f),r=%f\n\n",x1,y1,x2,y2,r); v1 = getvec(x1,y1); v2 = getvec(x2,y2); /* testing getvec,xval,yval procedure */ printf("xval(getvec(x1,y1)) = %f ",xval(v1)); printf("yval(getvec(x1,y1)) = %f\n",yval(v1)); printf("xval(getvec(x2,y2)) = %f ",xval(v2)); printf("yval(getvec(x2,y2)) = %f\n",yval(v2)); /* testing add procedure */ printf("xval(add( v1,v2 )) = %f ",xval(add(v1,v2))); printf("yval(add( v1,v2 )) = %f\n",yval(add(v1,v2))); /* testing mul procedure */ printf("xval(mul( r ,v1 )) = %f ",xval(mul(r,v1))); printf("yval(mul( r ,v1 )) = %f\n",yval(mul(r,v1))); printf("xval(mul( r ,v2 )) = %f ",xval(mul(r,v2))); printf("yval(mul( r, v2 )) = %f\n\n",yval(mul(r,v2))); } /* end test */ /* main function */ int main() { test(1,1,2,3,5); test(10.5,-7.6,4,-6,2); test(10.5,-6.5,4.6,-7.6,-2); test(xval(zero),yval(zero),2,3,-2.5); /* show linklist:test only,delete later */ showlist(); return 0; } /* end main */ /* the end of testvectors.c */