int main( int argc, char **argv ) { int i; int count; const char **orig; char buf[100]; maa_init( argv[0] ); if (argc == 1) { count = 100; } else if (argc != 2 ) { fprintf( stderr, "usage: stringtest count\n" ); return 1; } else { count = atoi( argv[1] ); } orig = xmalloc( count * sizeof( const char ** ) ); printf( "Running test for count of %d\n", count ); for (i = 0; i < count; i++) { sprintf( buf, "key%d", i ); orig[i] = str_find( buf ); } for (i = 0; i < count; i++) { const char *this; sprintf( buf, "key%d", i ); this = str_find( buf ); if (orig[i] != this) printf( "Pointers are different for \"%s\" (\"%s\"): %p and %p\n", buf, this, orig[i], this ); } xfree( orig ); printf( "Done.\n" ); return 0; }
int main( int argc, char **argv ) { sl_List sl; int count; int i; maa_init( argv[0] ); if (argc == 1) { count = 10; } else if (argc != 2 ) { fprintf( stderr, "usage: sltest count\n" ); return 1; } else { count = atoi( argv[1] ); } printf( "Running test for count of %d\n", count ); sl = sl_create( compare, key, NULL ); for (i = 1; i < count; i++) { printf( "adding %d\n", i ); sl_insert( sl, (void *) (intptr_t) i ); #ifdef DUMP _sl_dump( sl ); #endif } sl_iterate( sl, print ); printf( "\n" ); sl_delete( sl, (void *)5 ); sl_iterate( sl, print ); printf( "\n" ); sl_insert( sl, (void *)0 ); sl_iterate( sl, print ); printf( "\n" ); sl_insert( sl, (void *)66 ); sl_iterate( sl, print ); printf( "\n" ); sl_insert( sl, (void *)100 ); sl_iterate( sl, print ); printf( "\n" ); sl_insert( sl, (void *)-1 ); sl_iterate( sl, print ); printf( "\n" ); sl_insert( sl, (void *)5 ); sl_iterate( sl, print ); printf( "\n" ); sl_insert( sl, (void *)67 ); sl_iterate( sl, print ); printf( "\n" ); sl_insert( sl, (void *)68 ); sl_iterate( sl,print ); printf( "\n" ); sl_insert( sl, (void *)65 ); sl_iterate( sl, print ); printf( "\n" ); sl_destroy( sl ); return 0; }