gdi32: "StretchDIBits" with value of zero for "xSrc" and "ySrc"

Vitaliy Margolen wine-devel at
Tue Sep 23 19:29:59 CDT 2008

Mathias Kosch wrote:
>> +    assert(hDC != NULL);
>> dont' use assert() in the tests, especially for conditions such as
>> this which have nothing to do with the function you're testing. [...]
>> or use ok to check them if there's some reasonable probability they
>> may fail
> Vitaliy Margolen responded to my previous version of this patch:
>>> +     if (!pBitmapData)
>>> +             ok(0, "Memory allocation failed.\n");
>> Don't do this. If allocation failed assert or skip the test entirely.
> I'm a little confused now, because he told me to not use "ok" but
> suggested to assert.
Don't use assert for every single thing. In your test things like
GetDC(NULL) and CreateCompatibleDC(hDC) just have to succeed.  If they don't
something is really really wrong. And the whole test will just crash. So for
those things using assert is fine.

Memory allocations should "just work". No need to test for that. Or if you
really want to just gracefully skip the entire test in this case. But only
if it doesn't add too much complexity. Tests are made to test one thing at a

For calls that are related to what you testing and that should succeed like
StretchDIBits() and GetDIBits() just use ok() to test their result.

> +        for (x = 0; x < nWidth; x++)
> +        {
> +            if ((pStartLine[x+xSrc].rgbtBlue != pNewStartLine[x+xDest].rgbtBlue) ||
> +                    (pStartLine[x+xSrc].rgbtGreen != pNewStartLine[x+xDest].rgbtGreen) ||
> +                    (pStartLine[x+xSrc].rgbtRed != pNewStartLine[x+xDest].rgbtRed))
> +            {
> +        }
Just use memcpy here.


More information about the wine-devel mailing list