Listing 1
#ifdef AUTO_REGRESS int stack_regress( void ) { int a, test, ret; extern int push( int a ); extern int pop( int *a ); a = 1; do { /* Test 1 -- Empty stack test */ ret = pop( &test ); if (test != ERROR) break; /* Test 2 -- One push/pop test */ ret = push( a ); if (test == ERROR) break; ret = pop( &test ); if ((test == ERROR) || (a != test)) break; /* ... more tests, break on failure */ return( SUCCESS ); } while (0); printf("Stack Failure\n"); return( ERROR ); } #endif