// this is testlib.cpp #include #include #include #include #include #include #include #include #include "testlib.h" using namespace std; tester::tester(int c, char * * p, vector & v): vs(v), vcs(dvcs), as(das), acs(dacs) { argc=c; argv=p; isvec=true; isstr=true; prepare(); } tester::tester(int c, char * * p, vector & v): vs(dvs), vcs(v), as(das), acs(dacs) { argc=c; argv=p; isvec=true; isstr=false; prepare(); } tester::tester(int c, char * * p, string * & a): vs(dvs), vcs(dvcs), as(a), acs(dacs) { argc=c; argv=p; isvec=false; isstr=true; prepare(); } tester::tester(int c, char * * p, char * * & a) : vs(dvs), vcs(dvcs), as(das), acs(a) { argc=c; argv=p; isvec=false; isstr=false; prepare(); } tester::~tester() { } vector tester::dvs(0); vector tester::dvcs(0); string * tester::das = NULL; char * * tester::dacs = NULL; void tester::prepare() { minwidth=0; maxwidth=0; bigcheck=true; frac=0.0; time1=0.0; time2=0.0; int seed=0, len=0; origs=NULL; unrandom=false; printthem=false; bool show=false; for (int i=1; i=0) { int c=randy[pos]; c+=incr; if (c<='z') { randy[pos]=c; break; } else { c-='a'; incr=c/26; c%=26; randy[pos]=c+'a'; pos-=1; } } if (maxwidth<=minwidth) return; int extra = random()%(maxwidth-minwidth+1); for (int i=0; i0) { printf("Not correctly sorted: entry %d (%s) > entry %d (%s)\n", i-1, prev, i, curr); return false; } prev=curr; } return true; } } double tester::getcputime() { struct timeval tim; struct rusage ru; getrusage(RUSAGE_SELF, &ru); tim=ru.ru_utime; double t=(double)tim.tv_sec + (double)tim.tv_usec / 1000000.0; tim=ru.ru_stime; t+=(double)tim.tv_sec + (double)tim.tv_usec / 1000000.0; return t; } void tester::printall() { for (int i=0; i