Hi Austin,
ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#x.\n", hr); hr = IDirect3DSurface8_GetDesc(surface, &surface_desc); + ok(SUCCEEDED(hr), "GetDesc failed, hr %#x.\n", hr);
It's better to test for the exact value in tests like hr == S_OK. It makes tests stricter. I know there are already tests checking SUCCEEDED(), but while you are at this, let's get it right.
Also, patches should go to wine-patches ;)
Jacek
On 26 July 2011 10:57, Jacek Caban jacek@codeweavers.com wrote:
It's better to test for the exact value in tests like hr == S_OK. It makes tests stricter.
I don't think that making tests more strict than necessary is a good principle. (Not that it matters a lot here anyway, for most of these D3D_OK is the only possible sucessful return value.)
On 07/26/11 13:04, Henri Verbeet wrote:
On 26 July 2011 10:57, Jacek Caban jacek@codeweavers.com wrote:
It's better to test for the exact value in tests like hr == S_OK. It makes tests stricter.
I don't think that making tests more strict than necessary is a good principle.
If there is no cost of having tests more strict (like code complication), it is a good principle IMO. In this case it's a matter of choosing the right way for testing results, so it should be preferable.
(Not that it matters a lot here anyway, for most of these D3D_OK is the only possible sucessful return value.)
How can you be sure without tests?
Cheers, Jacek
On 26 July 2011 16:08, Jacek Caban jacek@codeweavers.com wrote:
If there is no cost of having tests more strict (like code complication), it is a good principle IMO. In this case it's a matter of choosing the right way for testing results, so it should be preferable.
We're not testing return codes here, so IMO we don't care about them beyond detecting failures early. As a general principle though, the point has always been to test behaviour that actual applications depend on, not finding the most obscure implementation details of native. Also, it's not unheard of for some of those details to change between Windows versions. If applications don't care, we don't either.
(Not that it matters a lot here anyway, for most of these D3D_OK is the only possible sucessful return value.)
How can you be sure without tests?
Well, aside from disassembling the entire thing for every single Windows version, you can't, even with tests. I mean, native D3D could do something obscure like switching all return codes to S_FALSE after drawing a green icosahedron, but I think it's somewhat unlikely.
On 07/26/11 16:34, Henri Verbeet wrote:
On 26 July 2011 16:08, Jacek Caban jacek@codeweavers.com wrote:
If there is no cost of having tests more strict (like code complication), it is a good principle IMO. In this case it's a matter of choosing the right way for testing results, so it should be preferable.
We're not testing return codes here, so IMO we don't care about them beyond detecting failures early. As a general principle though, the point has always been to test behaviour that actual applications depend on, not finding the most obscure implementation details of native. Also, it's not unheard of for some of those details to change between Windows versions. If applications don't care, we don't either.
I'm sure apps *do* care about return codes. It's not like we're talking about an obscure failure corner cases.
(Not that it matters a lot here anyway, for most of these D3D_OK is the only possible sucessful return value.)
How can you be sure without tests?
Well, aside from disassembling the entire thing for every single Windows version, you can't, even with tests.
Yeah, but with tests I can be much more confident saying so.
But first of all, I don't care about all versions and all corner cases, I care about the usual case. And that's something tests will show you easily.
I mean, native D3D could do something obscure like switching all return codes to S_FALSE after drawing a green icosahedron, but I think it's somewhat unlikely.
Seriously, I'm not talking about anything like that. We get to choose between using two things. SUCCEDEED() has no advantages over testing exact values in this context. Testing the exact value has a small, but still, advantage. I believe we agree on this. Then if you have a choice, you choose the one that is slightly better, even if you don't care about this advantage in this particular case.
Cheers, Jacek
On 26 July 2011 16:57, Jacek Caban jacek@codeweavers.com wrote:
Seriously, I'm not talking about anything like that. We get to choose between using two things. SUCCEDEED() has no advantages over testing exact values in this context. Testing the exact value has a small, but still, advantage. I believe we agree on this. Then if you have a choice,
No, I disagree with the basic idea that stricter tests are necessarily better. The advantage of SUCCEEDED is that it's *less* strict.
That said, the specific issue is insignificant enough that I wouldn't care about e.g. a new test using "hr == D3D_OK". I just don't think that changing existing tests from SUCCEEDED to "hr == D3D_OK" is really an improvement.
On 07/26/11 17:22, Henri Verbeet wrote:
On 26 July 2011 16:57, Jacek Caban jacek@codeweavers.com wrote:
Seriously, I'm not talking about anything like that. We get to choose between using two things. SUCCEDEED() has no advantages over testing exact values in this context. Testing the exact value has a small, but still, advantage. I believe we agree on this. Then if you have a choice,
No, I disagree with the basic idea that stricter tests are necessarily better. The advantage of SUCCEEDED is that it's *less* strict.
We won't agree on that.
That said, the specific issue is insignificant enough that I wouldn't care about e.g. a new test using "hr == D3D_OK". I just don't think that changing existing tests from SUCCEEDED to "hr == D3D_OK" is really an improvement.
Well, I didn't say anything about changing existing code and I didn't even try to reject a patch because of that. I was commenting a new code that had to be resent to wine-patches anyway, so I don't know what was the discussion about...
Cheers, Jacek
On Tuesday 26 July 2011 17:33:54 Jacek Caban wrote:
On 07/26/11 17:22, Henri Verbeet wrote:
No, I disagree with the basic idea that stricter tests are necessarily better. The advantage of SUCCEEDED is that it's *less* strict.
We won't agree on that.
I prefer comparison against S_OK(or D3D_OK, which is just S_OK) for the ok() lines and SUCCEEDED/FAILED for figuring out control flow inside the tests. At least until a Windows version or driver returns a success value other than D3D_OK.
But either way that's not a strong opinion. I am fine with either way, and I think I've used SUCCEEDED/FAILED myself for ok() statements mostly because Henri has used it and to keep the code consistent.