/* errors-test.c - Test program for error routines.
* © Copyright 1999 by John Halleck
* All rights reserved.
*/
/* Version of August 14th, 1999 */
#include <stdio.h>
#include "errors.h"
/* The standard errors package. */
#include "reportframe.h"
/* Lets make reporting easier */
int main() {
int temp;
error problem;
inittests("errors");
newtest ("printerror");
printf ("\nThe following should be a list of all the errors\n\n");
for (temp=1; temp<=maxERR; temp++) {
if (printerror((error) temp)) {
goterrorstat ("error code unrecognized", temp);
}
}
printf ("The list above should have all of its error codes in order,\n");
printf ("without gaps or duplicates\n");
printf ("\nThe following should report no error\n");
if (printerror((error )0)) {
goterror ("OK code not recognized(0)");
}
printf ("\n");
printf ("The following line should be an unidentified numeric error code\n");
if (!printerror((error) (maxERR+1))) {
goterrorstat ("out of range code OK. (%d)\n",maxERR+1);
}
printf ("\nThe following line should be the -1 out of range code.\n");
if (!printerror(-1)) {
goterror ("claims out of range code OK. (-1)");
}
printf ("\n");
endtest();
newtest ("clearerror");
lasterror = ERRfalse;
if ((problem = clearerror()))
goterrorstat ("Rejected valid call?", problem);
if (lasterror != NoError || lastfile != 0 || lastline != 0)
goterror ("Produced wrong results");
endtest ();
newtest ("noteerror");
if (ERRfalse != (problem = noteerror (ERRfalse, "Dummy false error")))
goterrorstat ("Rejected valid call?", problem);
if (lasterror != ERRfalse)
goterrorstat ("Produced wrong results", lasterror);
if ((problem = clearerror()))
goterrorstat ("clearerror had problems cleaning up after call.", problem);
if (lasterror)
goterrorstat ("clearerror didn't clean up after call", problem);
endtest ();
newtest ("dumperror");
if ((problem = clearerror()))
goterrorstat ("initial clearerror call failed", problem);
if (lasterror)
goterrorstat ("initial clearerror call didn't work", lasterror);
remark ("\nThere should be >>>NO<<< print between this line,");
if (ERRnotfound != (problem = dumperror()))
goterrorstat("Call rejected?", problem);
remark ("and this one.\n");
if (ERRfalse != (problem = noteerror(ERRfalse, "False to make error")))
goterrorstat ("noteerror call failed", problem);
remark ("There should be an ERRfalse error reported just below this line.");
if ((problem = dumperror()))
goterrorstat("Call rejected?", problem);
if ((problem = clearerror()))
goterrorstat ("clearerror call failed", problem);
if (lasterror)
goterrorstat ("clearerror call didn't work", lasterror);
printf ("\n");
endtest ();
newtest ("aborterror");
printf ("\n\nThere is no good way the abort routine can be checked\n");
printf ( "without killing the program, so aborterror has not really\n");
printf ( "been checked.\n\n");
endtest();
finalizetests();
return progerrors;
}
This page is http://www.cc.utah.edu/~nahaj/cave/survey/code/c/errors-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