d3dx9/tests: Clean up test_update_semantics() a bit.

Inspired by a patch from Eric Pouech <eric.pouech@gmail.com>.

Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Matteo Bruni 2021-11-19 20:50:27 +01:00 committed by Alexandre Julliard
parent 71c6f5b1ca
commit cee2d4c4c9

View file

@ -4739,11 +4739,9 @@ static void test_update_semantics(void)
D3DVERTEXELEMENT9 *decl_ptr; D3DVERTEXELEMENT9 *decl_ptr;
DWORD exp_vertex_size = sizeof(*vertices); DWORD exp_vertex_size = sizeof(*vertices);
DWORD vertex_size = 0; DWORD vertex_size = 0;
BYTE *decl_mem;
int equal; int equal;
int i = 0; int i = 0;
int *decl_mem;
int filler_a = 0xaaaaaaaa;
int filler_b = 0xbbbbbbbb;
test_context = new_test_context(); test_context = new_test_context();
if (!test_context) if (!test_context)
@ -4815,22 +4813,20 @@ static void test_update_semantics(void)
/* Check that GetDeclaration only writes up to the D3DDECL_END() marker and /* Check that GetDeclaration only writes up to the D3DDECL_END() marker and
* not the full MAX_FVF_DECL_SIZE elements. * not the full MAX_FVF_DECL_SIZE elements.
*/ */
memset(declaration, filler_a, sizeof(declaration)); memset(declaration, 0xaa, sizeof(declaration));
memcpy(declaration, declaration0, sizeof(declaration0)); memcpy(declaration, declaration0, sizeof(declaration0));
hr = mesh->lpVtbl->UpdateSemantics(mesh, declaration); hr = mesh->lpVtbl->UpdateSemantics(mesh, declaration);
ok(hr == D3D_OK, "Test UpdateSemantics, " ok(hr == D3D_OK, "Test UpdateSemantics, "
"got %#x expected D3D_OK\n", hr); "got %#x expected D3D_OK\n", hr);
memset(declaration, filler_b, sizeof(declaration)); memset(declaration, 0xbb, sizeof(declaration));
hr = mesh->lpVtbl->GetDeclaration(mesh, declaration); hr = mesh->lpVtbl->GetDeclaration(mesh, declaration);
ok(hr == D3D_OK, "Couldn't get vertex declaration. Got %#x, expected D3D_OK\n", hr); ok(hr == D3D_OK, "Couldn't get vertex declaration. Got %#x, expected D3D_OK\n", hr);
decl_mem = (int*)declaration; decl_mem = (BYTE *)declaration;
for (i = sizeof(declaration0)/sizeof(*decl_mem); i < sizeof(declaration)/sizeof(*decl_mem); i++) for (i = sizeof(declaration0); i < sizeof(declaration); ++i)
{ {
equal = memcmp(&decl_mem[i], &filler_b, sizeof(filler_b)); ok(decl_mem[i] == 0xbb, "Unexpected %#x.\n", decl_mem[i]);
ok(equal == 0, if (equal != 0)
"GetDeclaration wrote past the D3DDECL_END() marker. " break;
"Got %#x, expected %#x\n", decl_mem[i], filler_b);
if (equal != 0) break;
} }
/* UpdateSemantics does not check for overlapping fields */ /* UpdateSemantics does not check for overlapping fields */