Go to the documentation of this file.
85 #define MAXerrorCount 100
87 #define FOREACHint_( ints ) FOREACHsetelement_( i2T, ints, i2)
88 #define FOREACHint4_( ints ) FOREACHsetelement_( i2T, ints, i4)
89 #define FOREACHint_i_( qh, ints ) FOREACHsetelement_i_( qh, i2T, ints, i2)
90 #define FOREACHintreverse_( qh, ints ) FOREACHsetelementreverse_( qh, i2T, ints, i2)
91 #define FOREACHintreverse12_( ints ) FOREACHsetelementreverse12_( i2T, ints, i2)
97 char prompt[]=
"testqset_r N [M] [T5] -- Test reentrant qset_r.c and mem_r.c\n\
99 If this test fails then reentrant Qhull will not work.\n\
101 Test qsets of 0..N integers with a check every M iterations (default ~log10)\n\
102 Additional checking and logging if M is 1\n\
104 T5 turns on memory logging (qset does not log)\n\
113 #define fmax_( a,b ) ( ( a ) < ( b ) ? ( b ) : ( a ) )
138 static int needs_cr= 0;
140 size_t fmtlen= strlen(
fmt);
146 fprintf(stderr,
"QH6241 qh_fprintf: fp and qh not defined for '%s'",
fmt);
148 fprintf(stderr,
"QH6232 qh_fprintf: fp is 0. Was wrong qh_fprintf called for '%s'",
fmt);
152 if(
fmt[fmtlen-1]==
'\n'){
153 if(needs_cr && fmtlen>1){
161 if(msgcode>=6000 && msgcode<7000){
162 fprintf(fp,
"Error TQ%d ", msgcode);
170 int main(
int argc,
char **argv);
171 void readOptions(
qhT *
qh,
int argc,
char **argv,
const char *promptstr,
int *numInts,
int *checkEvery,
int *traceLevel);
183 int log_i(
qhT *
qh,
setT *set,
const char *s,
int i,
int numInts,
int checkEvery);
186 int main(
int argc,
char **argv) {
190 int curlong, totlong;
195 #if defined(_MSC_VER) && defined(_DEBUG) && defined(QHULL_CRTDBG)
196 _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) );
197 _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG );
198 _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDERR );
212 printf(
"\n\nNot testing qh_setduplicate and qh_setfree2.\n These routines use heap-allocated set contents. See qhull tests.\n");
216 if (curlong || totlong){
217 qh_fprintf(
qh, stderr, 8043,
"qh_memfreeshort: did not free %d bytes of long memory(%d pieces)\n", totlong, curlong);
224 printf(
"testqset_r: OK\n\n");
229 void readOptions(
qhT *
qh,
int argc,
char **argv,
const char *promptstr,
int *numInts,
int *checkEvery,
int *traceLevel)
236 if (argc < 2 || argc > 4) {
237 printf(
"%s", promptstr);
240 numIntsArg= strtol(argv[1], &endp, 10);
242 qh_fprintf(
qh, stderr, 6301,
"First argument should be 1 or greater. Got '%s'\n", argv[1]);
246 qh_fprintf(
qh, stderr, 6302,
"qset does not currently support 64-bit ints. Maximum count is %d\n",
MAXint);
249 *numInts= (int)numIntsArg;
251 if(argc==3 && argv[2][0]==
'T' && argv[2][1]==
'5' ){
255 if(argc==4 || (argc==3 && !isTracing)){
256 checkEveryArg= strtol(argv[2], &endp, 10);
258 qh_fprintf(
qh, stderr, 6321,
"checkEvery argument should be 1 or greater. Got '%s'\n", argv[2]);
262 qh_fprintf(
qh, stderr, 6322,
"qset does not currently support 64-bit ints. Maximum checkEvery is %d\n",
MAXint);
266 if(argv[3][0]==
'T' && argv[3][1]==
'5' ){
270 qh_fprintf(
qh, stderr, 6242,
"Optional third argument must be 'T5'. Got '%s'\n", argv[3]);
274 *checkEvery= (int)checkEveryArg;
281 if(numInts<0 || numInts*(
int)
sizeof(
int)<0){
282 qh_fprintf(
qh, stderr, 6303,
"qset does not currently support 64-bit ints. Integer overflow\n");
285 *intarray=
qh_malloc(numInts *
sizeof(
int));
287 qh_fprintf(
qh, stderr, 6304,
"Failed to allocate %d bytes of memory\n", numInts *
sizeof(
int));
290 for(i= 0; i<numInts; i++){
310 qh_fprintf(
qh, stderr, 8002,
"\n\nTesting qh_setappend 0..%d. Test", numInts-1);
311 for(i= 0; i<numInts; i++){
312 isCheck=
log_i(
qh,
ints,
"i", i, numInts, checkEvery);
319 qh_fprintf(
qh, stderr, 8014,
"\n\nTesting qh_settruncate %d and 0. Test", numInts/2);
321 isCheck=
log_i(
qh,
ints,
"n", numInts/2, numInts, checkEvery);
325 isCheck=
log_i(
qh,
ints,
"n", 0, numInts, checkEvery);
329 qh_fprintf(
qh, stderr, 8003,
"\n\nTesting qh_setappend2ndlast 0,0..%d. Test 0", numInts-1);
333 for(i= 0; i<numInts; i++){
334 isCheck=
log_i(
qh,
ints,
"i", i, numInts, checkEvery);
340 qh_fprintf(
qh, stderr, 8015,
"\n\nTesting SETtruncate_ %d and 0. Test", numInts/2);
342 isCheck=
log_i(
qh,
ints,
"n", numInts/2, numInts, checkEvery);
346 isCheck=
log_i(
qh,
ints,
"n", 0, numInts, checkEvery);
358 qh_fprintf(
qh, stderr, 8003,
"\n\nTesting qh_setdelnthsorted and qh_setaddnth 1..%d. Test", numInts-1);
359 for(j=1; j<numInts; j++){
365 for(i= 0; i<j && i<100; i++){
366 isCheck=
log_i(
qh,
ints,
"", i, numInts, checkEvery);
386 qh_fprintf(
qh, stderr, 8016,
"\n\nTesting qh_setappend_set 0..%d. Test", numInts-1);
387 for(j=0; j<numInts; j++){
396 for(i= 0; i<=j && i<=20; i++){
424 qh_fprintf(
qh, stderr, 8017,
"\n\nTesting qh_setcompact and qh_setcopy 0..%d. Test", numInts-1);
425 for(j=0; j<numInts; j++){
428 for(k= 0; k<i%7; k++){
453 qh_fprintf(
qh, stderr, 8018,
"\n\nTesting qh_setdel*, qh_setaddsorted, and 0..%d. Test", numInts-1);
454 for(j=0; j<numInts; j++){
509 qh_fprintf(
qh, stderr, 8019,
"\n\nTesting qh_setequal*, qh_setin*, qh_setdel, qh_setdelnth, and qh_setlarger 0..%d. Test", numInts-1);
510 for(j=0; j<numInts; j++){
520 qh_fprintf(
qh, stderr, 6300,
"testSetequalInEtc: set not equal to itself at length %d\n", j);
524 qh_fprintf(
qh, stderr, 6323,
"testSetequalInEtc: empty set not equal to null set\n");
529 qh_fprintf(
qh, stderr, 6324,
"testSetequalInEtc: non-empty set equal to empty set\n", j);
544 qh_fprintf(
qh, stderr, 6325,
"testSetequalInEtc: modified set equal to original set at %d/2\n", j);
548 qh_fprintf(
qh, stderr, 6326,
"qh_setequal_except: modified set not equal to original set except modified\n", j);
552 qh_fprintf(
qh, stderr, 6327,
"qh_setequal_except: modified set equal to original set with wrong excepts\n", j);
556 qh_fprintf(
qh, stderr, 6328,
"qh_setequal_skip: modified set not equal to original set except modified\n", j);
560 qh_fprintf(
qh, stderr, 6329,
"qh_setequal_skip: modified set equal to original set with wrong excepts\n", j);
563 if(intarray+j/2+1!=
qh_setdel(ints3, intarray+j/2+1)){
564 qh_fprintf(
qh, stderr, 6330,
"qh_setdel: failed to find added element\n", j);
573 qh_fprintf(
qh, stderr, 6331,
"qh_setin: found deleted element\n");
576 if(j>4 && !
qh_setin(ints3, intarray+1)){
577 qh_fprintf(
qh, stderr, 6332,
"qh_setin: did not find second element\n");
580 if(j>4 && !
qh_setin(ints3, intarray+j-2)){
581 qh_fprintf(
qh, stderr, 6333,
"qh_setin: did not find last element\n");
585 qh_fprintf(
qh, stderr, 6334,
"qh_setindex: found element in empty set\n");
589 qh_fprintf(
qh, stderr, 6335,
"qh_setindex: found deleted element in set\n");
593 qh_fprintf(
qh, stderr, 6336,
"qh_setindex: did not find first in set\n");
597 qh_fprintf(
qh, stderr, 6337,
"qh_setindex: did not find last in set\n");
618 qh_fprintf(
qh, stderr, 8020,
"\n\nTesting qh_setlast, qh_setnew_delnthsorted, qh_setunique, and qh_setzero 0..%d. Test", numInts-1);
619 for(j=0; j<numInts; j++){
623 qh_fprintf(
qh, stderr, 6340,
"qh_setunique: not able to append next element %d\n", i);
630 qh_fprintf(
qh, stderr, 6341,
"qh_setunique: appended next element twice %d\n", i);
634 qh_fprintf(
qh, stderr, 6346,
"qh_setunique: appended middle element twice %d/2\n", i);
640 qh_fprintf(
qh, stderr, 6339,
"qh_setlast: returned last element of empty set\n");
645 qh_fprintf(
qh, stderr, 6338,
"qh_setlast: wrong last element\n");
648 prepend= (j<100 ? j/4 : 0);
651 qh_fprintf(
qh, stderr, 6345,
"qh_setnew_delnthsorted: Expecting %d elements, got %d\n", j+prepend-1,
qh_setsize(
qh, ints2));
655 for(i= 0; i<prepend; i++){
659 for(i= 0; i<prepend; i++){
689 qh_fprintf(
qh, stderr, 8021,
"\n\nTesting qh_settemp* 0..%d. Test", numInts-1);
690 for(j=0; j<numInts; j++){
706 qh_fprintf(
qh, stderr, 6343,
"qh_settemppop: didn't pop the push\n");
731 if(*s || checkEvery==1){
735 if(i==11 && checkEvery==1){
757 if(i<1000 || i%checkEvery==0 || i== scale || i==numInts-1){
788 qh_fprintf(
qh, stderr, 6305,
"%s: SETreturnsize_(qh) returned %d while qh_setsize(qh) returns %d\n",
name, actualSize,
qh_setsize(
qh, set));
790 }
else if(actualSize!=count){
791 qh_fprintf(
qh, stderr, 6306,
"%s: Expecting %d elements for set. Got %d elements\n",
name, count, actualSize);
796 qh_fprintf(
qh, stderr, 6307,
"%s: Got empty set instead of count %d, rangeA %d, rangeB %d, rangeC %d\n",
name, count, rangeA, rangeB, rangeC);
827 qh_fprintf(
qh, stderr, 6311,
"%s: Expecting SETindex_(set, pointer-to-%d) to be %d. Got %d\n",
name, *i2, i,
SETindex_(set, i2));
831 qh_fprintf(
qh, stderr, 6312,
"%s: SETref_(i2) [%p] does not point to i2 (the %d'th element)\n",
name,
SETref_(i2), i);
840 qh_fprintf(
qh, stderr, 6320,
"%s: SETelemaddr_(set, %d, i2T) [%p] does not point to i2\n",
name, i2_i,
SETelemaddr_(set, i2_i,
int));
845 qh_fprintf(
qh, stderr, 6314,
"%s: First element is %d instead of SETfirst %d\n",
name, *i2, first);
849 qh_fprintf(
qh, stderr, 6315,
"%s: starts with %d instead of rangeA %d\n",
name, *i2, rangeA);
854 if(i2_i==1 && second!=*i2){
855 qh_fprintf(
qh, stderr, 6316,
"%s: Second element is %d instead of SETsecond %d\n",
name, *i2, second);
865 }
else if(rangeB==-1 && *i2==rangeC){
871 qh_fprintf(
qh, stderr, 6317,
"%s: Expecting %d'th element to be %d. Got %d\n",
name, i2_i, prev, *i2);
877 qh_fprintf(
qh, stderr, 6318,
"%s: SETelem_(set, %d) [%p] is not i2 [%p] (the %d'th element)\n",
name, i2_i,
SETelem_(set, i2_i), i2, i2_i);
881 qh_fprintf(
qh, stderr, 6319,
"%s: SETelemt_(set, %d, i2T) [%p] is not SETelem_(set, %d) [%p] (the %d'th element)\n",
name, i2_i,
SETelemt_(set, i2_i,
int), i2_i,
SETelem_(set, i2_i), i2_i);
void * qh_setdelsorted(setT *set, void *oldelem)
void qh_meminitbuffers(int tracelevel, int alignment, int numsizes, int bufsize, int bufinit)
void qh_setappend_set(setT **setp, setT *setA)
void qh_setfreelong(setT **setp)
int main(int argc, char **argv)
void * qh_setdelnthsorted(setT *set, int nth)
#define FOREACHint_(ints)
void checkSetContents(qhT *qh, const char *name, setT *set, int count, int rangeA, int rangeB, int rangeC)
#define SETelemaddr_(set, n, type)
void testSetcompactCopy(qhT *qh, int numInts, int *intarray, int checkEvery)
void * qh_setdel(setT *set, void *oldelem)
int qh_setunique(setT **set, void *elem)
void qh_settemppush(setT *set)
void * qh_setdelnth(setT *set, int nth)
void testSettemp(qhT *qh, int numInts, int *intarray, int checkEvery)
void * qh_setlast(setT *set)
void qh_setfree(setT **setp)
void qh_setlarger(setT **oldsetp)
setT * qh_setcopy(setT *set, int extra)
#define SETsecondt_(set, type)
void qh_setappend2ndlast(setT **setp, void *newelem)
void qh_memsize(int size)
#define SETelemt_(set, n, type)
void qh_setappend(setT **setp, void *newelem)
void * qh_setdellast(setT *set)
#define SETreturnsize_(set, size)
setT * qh_settemp(int setsize)
void qh_settruncate(setT *set, int size)
void qh_exit(int exitcode)
int log_i(qhT *qh, setT *set, const char *s, int i, int numInts, int checkEvery)
int qh_setequal_skip(setT *setA, int skipA, setT *setB, int skipB)
int qh_setequal_except(setT *setA, void *skipelemA, setT *setB, void *skipelemB)
int qh_setequal(setT *setA, setT *setB)
int qh_setsize(setT *set)
void testSetequalInEtc(qhT *qh, int numInts, int *intarray, int checkEvery)
#define SETtruncate_(set, size)
void qh_fprintf(qhT *qh, FILE *fp, int msgcode, const char *fmt,...)
void qh_setaddsorted(setT **setp, void *newelem)
setT * qh_settemppop(void)
setT * qh_setnew(int setsize)
void testSetdelSetadd(qhT *qh, int numInts, int *intarray, int checkEvery)
#define SETaddr_(set, type)
void testSetlastEtc(qhT *qh, int numInts, int *intarray, int checkEvery)
void readOptions(qhT *qh, int argc, char **argv, const char *promptstr, int *numInts, int *checkEvery, int *traceLevel)
void qh_setreplace(setT *set, void *oldelem, void *newelem)
void qh_settempfree_all(void)
void setupMemory(qhT *qh, int tracelevel, int numInts, int **intarray)
#define SETfirstt_(set, type)
void qh_memfreeshort(int *curlong, int *totlong)
void qh_settempfree(setT **set)
void testSetappendSet(qhT *qh, int numInts, int *intarray, int checkEvery)
void qh_setaddnth(setT **setp, int nth, void *newelem)
int qh_setindex(setT *set, void *atelem)
void ** qh_setendpointer(setT *set)
void qh_setzero(setT *set, int idx, int size)
void qh_meminit(FILE *ferr)
void testSetappendSettruncate(qhT *qh, int numInts, int *intarray, int checkEvery)
void qh_fprintf_stderr(int msgcode, const char *fmt,...)
#define SETindex_(set, elem)
void qh_errexit(qhT *qh, int exitcode, facetT *f, ridgeT *r)
#define FOREACHint_i_(qh, ints)
void testSetdelsortedEtc(qhT *qh, int numInts, int *intarray, int checkEvery)
setT * qh_setnew_delnthsorted(setT *set, int size, int nth, int prepend)
int qh_setin(setT *set, void *setelem)
void qh_setcompact(setT *set)
void qh_memstatistics(FILE *fp)
void qh_setcheck(setT *set, const char *tname, unsigned id)
void * qh_malloc(size_t size)
hpp-fcl
Author(s):
autogenerated on Fri Aug 2 2024 02:45:15