Exemplo n.º 1
0
int main(void)
{
	const int arr[] = { INT_MIN, 0, 1, 2, 3, 4, 5, 6, INT_MAX };
	unsigned int start, num, i, total = 0;
	int key;

	plan_tests(285);

	for (start = 0; start < ARRAY_SIZE(arr); start++) {
		for (num = 0; num < ARRAY_SIZE(arr) - start; num++) {
			key = 7;
			ok1(asearch(&key, &arr[start], num, test_cmp) == NULL);
			total++;
			for (i = start; i < start+num; i++) {
				const int *ret;
				key = arr[i];
				ret = asearch(&key, &arr[start], num, test_cmp);
				ok1(ret);
				ok1(ret && *ret == key);
				total++;
			}
		}
	}
	diag("Tested %u searches\n", total);
	return exit_status();
}
Exemplo n.º 2
0
bool MComponent::addFromMask( WFileName& search, WString& err )
{
    bool ok = true;
    WFileName asearch( search );
    asearch.absoluteTo( _filename );
    DIR* dir = opendir( asearch );
    if( !dir ) {
        err.printf( "no files found for '%s'", (const char*)search );
        ok = false;
    } else {
        for(;;) {
            struct dirent* ent = readdir( dir );
            if( !ent ) break;
            WFileName newfile( ent->d_name );
            newfile.setDrive( search.drive() );
            newfile.setDir( search.dir() );
//            newfile.toLower();
            if( !addFromFilename( newfile, err ) ) {
                ok = false;
                break;
            }
        }
        closedir( dir );
    }
    return( ok );
}
int main(void)
{
	const char key[] = "key";
	const char *elems[] = { "a", "big", "list", "of", "things" };

#ifdef FAIL
	char **p;
#if !HAVE_TYPEOF
#error "Unfortunately we don't fail if no typeof."
#endif
#else
	const char **p;
#endif
	p = asearch(key, elems, ARRAY_SIZE(elems), cmp);
	return p ? 0 : 1;
}