[1/2] kernel32/tests: add tests for GetDllDirectoryA

Vitaliy Margolen wine-devel at kievinfo.com
Sun Nov 6 11:04:06 CST 2011


On 11/06/2011 09:14 AM, Thomas Faber wrote:
>

> +        length = strlen(dll_directories[i]);
> +        assert(sizeof(buffer) > length + 1);
Please don't do this. Tests shouldn't assert because programmer failed to 
pick the right buffer size of hard-coded strings.

> +        ok(GetLastError() == 0xdeadbeef, "Error is %u\n", GetLastError());
You should get value of GetLastError() before the ok check here. See all 
places that check values of GetLastError().

> +        ok(buffer[length + 1] == 'A', "i=%d, Buffer overflow\n", i);
> +        ok(buffer[ret] == 0, "i=%d, Wrong length or not null terminated\n", i);
> +        ok(strcmp(buffer, dll_directories[i]) == 0, "i=%d, Wrong path returned: '%s'\n", i, buffer);
You can do all these with one memcmp call.
>
> +        ok(buffer[length + 1] == 'A', "i=%d, Buffer overflow\n", i);
> +        ok(buffer[ret] == 0, "i=%d, Wrong length or not null terminated\n", i);
> +        for (j = 0; buffer[j]; j++)
> +            if (buffer[j] != dll_directories[i][j])
> +            {
> +                ok(0, "i=%d, Wrong path returned: %s\n", i, wine_dbgstr_w(buffer));
> +                break;
> +            }
Same for this.

> +        ok(buffer[0] == 0 || /* XP, 2003 */
> +           buffer[0] == 'A', "i=%d, Buffer overflow\n", i);
Please mark bad case with broke() to check for correct Wine behavior.

Also please combine A & W tests. They do mostly the same things.

Vitaliy.



More information about the wine-devel mailing list