00001
00002
00003
00004
00005
00006
00007 #include <stddef.h>
00008
00009 #include <stdio.h>
00010 #include <stdarg.h>
00011
00012 #include "error.h"
00013 #include "tests.h"
00014
00015
00016
00017
00018 void
00019 error(const char *fmt, ...)
00020 {
00021 va_list args ;
00022
00023 va_start(args, fmt) ;
00024 if (nfails <= max_nmpt)
00025 (void) vfprintf(stderr,fmt,args) ;
00026 va_end(args) ;
00027 }
00028
00029
00030
00031
00032
00033 void
00034 print(const char *fmt, ...)
00035 {
00036 va_list args ;
00037
00038 va_start(args, fmt) ;
00039 (void) vfprintf(stderr,fmt,args) ;
00040 va_end(args) ;
00041 }
00042
00043
00044
00045
00046 int
00047 ifFail(const int expr, const int line, const char *file)
00048 {
00049 if (expr) {
00050 ++nfails;
00051 error("\n\tFAILURE at line %d of %s: ", line, file);
00052 }
00053 return expr;
00054 }
00055
00056
00057
00058
00059
00060 void
00061 print_n_size_t(size_t nelems, const size_t *array)
00062 {
00063 fprintf(stderr, "[");
00064 while(nelems-- > 0)
00065 {
00066 fprintf(stderr, "%ld", (long)*array++);
00067 if(nelems > 0)
00068 fprintf(stderr, " ");
00069 }
00070 fprintf(stderr, "]");
00071 }