/* enorm-test.c - test routine for enorm routines.
* © Copyright 1999 by John Halleck
* All Rights Reserved.
*/
/* Version of August 14th, 1999 */
#include <stdio.h>
#include <math.h>
#include "enorm.h"
/* Routines we are testing */
#include "reportframe.h"
/* Standard form of test output */
#define FUDGE 0.0000001
/* How close is "close enough" for these tests? */
int main(){
int i, j;
double z, ours, diff;
inittests("enorm");
newtest("enorm");
for (i=0; i<15; i++) for (j=0; j<=15; j++) {
z = sqrt ( (double) (i*i+j*j) );
ours = enorm2 ( (double) i, (double) j);
diff = z - ours;
if (diff<0) diff = -diff;
if (diff > FUDGE) {
if (!testerrors) {
goterror ("enorm produced wrong answer");
printf ("(%f vs our %f)\n", z, ours);
}
}
}
endtest();
finalizetests();
return progerrors;
}
This page is http://www.cc.utah.edu/~nahaj/cave/survey/code/c/enorm-test.c.html
© Copyright 2000 by John Halleck, All Rights Reserved.
This snapshot was last modified on August 23rd, 2000
And the underlying file was last modified on May 11th, 2000