Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- dlls/ddraw/tests/ddraw7.c | 167 +++++++++++++++++++++++----------------------- 1 file changed, 82 insertions(+), 85 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 91822281d06..7c6264bd557 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -32,6 +32,10 @@ static DEVMODEW registry_mode;
static HRESULT (WINAPI *pDwmIsCompositionEnabled)(BOOL *);
+#ifndef ARRAY_SIZE +#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) +#endif + struct vec2 { float x, y; @@ -1519,7 +1523,7 @@ static void test_ck_rgba(void) hr = IDirect3DDevice7_GetRenderTarget(device, &rt); ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, tests[i].color_key); ok(SUCCEEDED(hr), "Failed to enable color keying, hr %#x.\n", hr); @@ -1998,7 +2002,7 @@ static void test_surface_qi(void) hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL); ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
- test_qi("surface_qi", (IUnknown *)surface, &IID_IDirectDrawSurface7, tests, sizeof(tests) / sizeof(*tests)); + test_qi("surface_qi", (IUnknown *)surface, &IID_IDirectDrawSurface7, tests, ARRAY_SIZE(tests));
IDirectDrawSurface7_Release(surface); IDirectDraw7_Release(ddraw); @@ -2064,7 +2068,7 @@ static void test_device_qi(void) return; }
- test_qi("device_qi", (IUnknown *)device, &IID_IDirect3DDevice7, tests, sizeof(tests) / sizeof(*tests)); + test_qi("device_qi", (IUnknown *)device, &IID_IDirect3DDevice7, tests, ARRAY_SIZE(tests));
IDirect3DDevice7_Release(device); DestroyWindow(window); @@ -3732,7 +3736,7 @@ static void test_lighting(void) hr = IDirect3DDevice7_LightEnable(device, 0, TRUE); ok(SUCCEEDED(hr), "Failed to enable light 0, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_WORLD, tests[i].world_matrix); ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr); @@ -3944,22 +3948,14 @@ static void test_specular_lighting(void) } tests[] = { - {&directional, FALSE, 30.0f, expected_directional, - sizeof(expected_directional) / sizeof(expected_directional[0])}, - {&directional, TRUE, 30.0f, expected_directional_local, - sizeof(expected_directional_local) / sizeof(expected_directional_local[0])}, - {&point, FALSE, 30.0f, expected_point, - sizeof(expected_point) / sizeof(expected_point[0])}, - {&point, TRUE, 30.0f, expected_point_local, - sizeof(expected_point_local) / sizeof(expected_point_local[0])}, - {&spot, FALSE, 30.0f, expected_spot, - sizeof(expected_spot) / sizeof(expected_spot[0])}, - {&spot, TRUE, 30.0f, expected_spot_local, - sizeof(expected_spot_local) / sizeof(expected_spot_local[0])}, - {&point_range, FALSE, 30.0f, expected_point_range, - sizeof(expected_point_range) / sizeof(expected_point_range[0])}, - {&point_side, TRUE, 0.0f, expected_point_side, - sizeof(expected_point_side) / sizeof(expected_point_side[0])}, + {&directional, FALSE, 30.0f, expected_directional, ARRAY_SIZE(expected_directional)}, + {&directional, TRUE, 30.0f, expected_directional_local, ARRAY_SIZE(expected_directional_local)}, + {&point, FALSE, 30.0f, expected_point, ARRAY_SIZE(expected_point)}, + {&point, TRUE, 30.0f, expected_point_local, ARRAY_SIZE(expected_point_local)}, + {&spot, FALSE, 30.0f, expected_spot, ARRAY_SIZE(expected_spot)}, + {&spot, TRUE, 30.0f, expected_spot_local, ARRAY_SIZE(expected_spot_local)}, + {&point_range, FALSE, 30.0f, expected_point_range, ARRAY_SIZE(expected_point_range)}, + {&point_side, TRUE, 0.0f, expected_point_side, ARRAY_SIZE(expected_point_side)}, }; IDirect3DDevice7 *device; IDirectDrawSurface7 *rt; @@ -4032,7 +4028,7 @@ static void test_specular_lighting(void) hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_SPECULARENABLE, TRUE); ok(SUCCEEDED(hr), "Failed to enable specular lighting, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { hr = IDirect3DDevice7_SetLight(device, 0, tests[i].light); ok(SUCCEEDED(hr), "Failed to set light parameters, hr %#x.\n", hr); @@ -4320,7 +4316,7 @@ static void test_fog_special(void) hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGEND, conv.d); ok(SUCCEEDED(hr), "Failed to set fog end, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); i++) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x000000ff, 1.0f, 0); ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr); @@ -4512,7 +4508,7 @@ static void test_lighting_interface_versions(void) ok(SUCCEEDED(hr), "Failed to get specularenable render state, hr %#x.\n", hr); ok(rs == FALSE, "Initial D3DRENDERSTATE_SPECULARENABLE is %#x, expected FALSE.\n", rs);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); i++) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff202020, 0.0f, 0); ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr); @@ -4748,7 +4744,7 @@ static void test_texturemanage(void) return; }
- for (i = 0; i < sizeof(tests) / sizeof(*tests); i++) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); @@ -4954,7 +4950,7 @@ static void test_block_formats_creation(void) ok(SUCCEEDED(hr), "Failed to get fourcc codes %#x.\n", hr); for (i = 0; i < num_fourcc_codes; i++) { - for (j = 0; j < sizeof(formats) / sizeof(*formats); j++) + for (j = 0; j < ARRAY_SIZE(formats); ++j) { if (fourcc_codes[i] == formats[j].fourcc) supported_overlay_fmts |= formats[j].support_flag; @@ -4969,9 +4965,9 @@ static void test_block_formats_creation(void)
mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 2 * 2 * 16 + 1);
- for (i = 0; i < sizeof(formats) / sizeof(*formats); i++) + for (i = 0; i < ARRAY_SIZE(formats); ++i) { - for (j = 0; j < sizeof(types) / sizeof(*types); j++) + for (j = 0; j < ARRAY_SIZE(types); ++j) { BOOL support;
@@ -5035,7 +5031,7 @@ static void test_block_formats_creation(void) if (formats[i].overlay) continue;
- for (j = 0; j < sizeof(user_mem_tests) / sizeof(*user_mem_tests); ++j) + for (j = 0; j < ARRAY_SIZE(user_mem_tests); ++j) { memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); @@ -5164,13 +5160,13 @@ static void test_unsupported_formats(void) ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr); IDirect3D7_Release(d3d);
- for (i = 0; i < sizeof(formats) / sizeof(*formats); i++) + for (i = 0; i < ARRAY_SIZE(formats); ++i) { struct format_support_check check = {&formats[i].fmt, FALSE}; hr = IDirect3DDevice7_EnumTextureFormats(device, test_unsupported_formats_cb, &check); ok(SUCCEEDED(hr), "Failed to enumerate texture formats %#x.\n", hr);
- for (j = 0; j < sizeof(caps) / sizeof(*caps); j++) + for (j = 0; j < ARRAY_SIZE(caps); ++j) { memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); @@ -5441,7 +5437,7 @@ static void test_rt_caps(void) hr = IDirectDraw7_CreatePalette(ddraw, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, palette_entries, &palette, NULL); ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
- for (i = 0; i < sizeof(test_data) / sizeof(*test_data); ++i) + for (i = 0; i < ARRAY_SIZE(test_data); ++i) { IDirectDrawSurface7 *surface, *rt, *expected_rt, *tmp; DDSURFACEDESC2 surface_desc; @@ -5663,7 +5659,7 @@ static void test_primary_caps(void) ddraw = create_ddraw(); ok(!!ddraw, "Failed to create a ddraw object.\n");
- for (i = 0; i < sizeof(test_data) / sizeof(*test_data); ++i) + for (i = 0; i < ARRAY_SIZE(test_data); ++i) { hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, test_data[i].coop_level); ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr); @@ -5860,7 +5856,7 @@ static void test_surface_lock(void)
IDirectDrawSurface7_Release(surface);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); i++) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { if (!cubemap_supported && tests[i].caps2 & DDSCAPS2_CUBEMAP) continue; @@ -5962,7 +5958,7 @@ static void test_surface_discard(void) hr = IDirect3DDevice7_GetRenderTarget(device, &target); ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); i++) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { BOOL discarded;
@@ -6076,7 +6072,7 @@ static void test_flip(void) hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
- for (i = 0; i < sizeof(test_data) / sizeof(*test_data); ++i) + for (i = 0; i < ARRAY_SIZE(test_data); ++i) { /* Creating a flippable texture induces a BSoD on some versions of the * Intel graphics driver. At least Intel GMA 950 with driver version @@ -6580,8 +6576,9 @@ static void test_set_surface_desc(void)
/* SetSurfaceDesc needs systemmemory surfaces. * - * As a sidenote, fourcc surfaces aren't allowed in sysmem, thus testing DDSD_LINEARSIZE is moot. */ - for (i = 0; i < sizeof(invalid_caps_tests) / sizeof(*invalid_caps_tests); i++) + * As a sidenote, fourcc surfaces aren't allowed in sysmem, thus testing + * DDSD_LINEARSIZE is moot. */ + for (i = 0; i < ARRAY_SIZE(invalid_caps_tests); ++i) { reset_ddsd(&ddsd); ddsd.dwFlags = DDSD_CAPS; @@ -7612,7 +7609,7 @@ static void test_create_surface_pitch(void)
mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ((63 * 4) + 8) * 63);
- for (i = 0; i < sizeof(test_data) / sizeof(*test_data); ++i) + for (i = 0; i < ARRAY_SIZE(test_data); ++i) { memset(&surface_desc, 0, sizeof(surface_desc)); surface_desc.dwSize = sizeof(surface_desc); @@ -7725,7 +7722,7 @@ static void test_mipmap(void) return; }
- for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { memset(&surface_desc, 0, sizeof(surface_desc)); surface_desc.dwSize = sizeof(surface_desc); @@ -8004,7 +8001,7 @@ static void test_p8_blit(void)
if (SUCCEEDED(hr)) { - for (x = 0; x < sizeof(expected) / sizeof(*expected); x++) + for (x = 0; x < ARRAY_SIZE(expected); ++x) { color = get_surface_color(dst, x, 0); todo_wine ok(compare_color(color, expected[x], 0), @@ -8174,16 +8171,16 @@ static void test_palette_gdi(void) "Got unexpected palette %p, expected %p.\n", ddraw_palette_handle, GetStockObject(DEFAULT_PALETTE));
- i = GetDIBColorTable(dc, 0, sizeof(rgbquad) / sizeof(*rgbquad), rgbquad); - ok(i == sizeof(rgbquad) / sizeof(*rgbquad), "Expected count 255, got %u.\n", i); - for (i = 0; i < sizeof(expected1) / sizeof(*expected1); i++) + i = GetDIBColorTable(dc, 0, ARRAY_SIZE(rgbquad), rgbquad); + ok(i == ARRAY_SIZE(rgbquad), "Expected count 255, got %u.\n", i); + for (i = 0; i < ARRAY_SIZE(expected1); ++i) { ok(!memcmp(&rgbquad[i], &expected1[i], sizeof(rgbquad[i])), "Got color table entry %u r=%#x g=%#x b=%#x, expected r=%#x g=%#x b=%#x.\n", i, rgbquad[i].rgbRed, rgbquad[i].rgbGreen, rgbquad[i].rgbBlue, expected1[i].rgbRed, expected1[i].rgbGreen, expected1[i].rgbBlue); } - for (; i < sizeof(rgbquad) / sizeof(*rgbquad); i++) + for (; i < ARRAY_SIZE(rgbquad); ++i) { ok(!memcmp(&rgbquad[i], &rgb_zero, sizeof(rgbquad[i])), "Got color table entry %u r=%#x g=%#x b=%#x, expected r=0 g=0 b=0.\n", @@ -8223,16 +8220,16 @@ static void test_palette_gdi(void) /* Refresh the DC. This updates the palette. */ hr = IDirectDrawSurface7_GetDC(surface, &dc); ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr); - i = GetDIBColorTable(dc, 0, sizeof(rgbquad) / sizeof(*rgbquad), rgbquad); - ok(i == sizeof(rgbquad) / sizeof(*rgbquad), "Expected count 255, got %u.\n", i); - for (i = 0; i < sizeof(expected2) / sizeof(*expected2); i++) + i = GetDIBColorTable(dc, 0, ARRAY_SIZE(rgbquad), rgbquad); + ok(i == ARRAY_SIZE(rgbquad), "Expected count 255, got %u.\n", i); + for (i = 0; i < ARRAY_SIZE(expected2); ++i) { ok(!memcmp(&rgbquad[i], &expected2[i], sizeof(rgbquad[i])), "Got color table entry %u r=%#x g=%#x b=%#x, expected r=%#x g=%#x b=%#x.\n", i, rgbquad[i].rgbRed, rgbquad[i].rgbGreen, rgbquad[i].rgbBlue, expected2[i].rgbRed, expected2[i].rgbGreen, expected2[i].rgbBlue); } - for (; i < sizeof(rgbquad) / sizeof(*rgbquad); i++) + for (; i < ARRAY_SIZE(rgbquad); ++i) { ok(!memcmp(&rgbquad[i], &rgb_zero, sizeof(rgbquad[i])), "Got color table entry %u r=%#x g=%#x b=%#x, expected r=0 g=0 b=0.\n", @@ -8296,16 +8293,16 @@ static void test_palette_gdi(void) * the system palette are not included pending an application that depends on this. * The relation between those causes problems on Windows Vista and newer for games * like Age of Empires or StarcCaft. Don't emulate it without a real need. */ - i = GetDIBColorTable(dc, 0, sizeof(rgbquad) / sizeof(*rgbquad), rgbquad); - ok(i == sizeof(rgbquad) / sizeof(*rgbquad), "Expected count 255, got %u.\n", i); - for (i = 0; i < sizeof(expected2) / sizeof(*expected2); i++) + i = GetDIBColorTable(dc, 0, ARRAY_SIZE(rgbquad), rgbquad); + ok(i == ARRAY_SIZE(rgbquad), "Expected count 255, got %u.\n", i); + for (i = 0; i < ARRAY_SIZE(expected2); ++i) { ok(!memcmp(&rgbquad[i], &expected2[i], sizeof(rgbquad[i])), "Got color table entry %u r=%#x g=%#x b=%#x, expected r=%#x g=%#x b=%#x.\n", i, rgbquad[i].rgbRed, rgbquad[i].rgbGreen, rgbquad[i].rgbBlue, expected2[i].rgbRed, expected2[i].rgbGreen, expected2[i].rgbBlue); } - for (; i < sizeof(rgbquad) / sizeof(*rgbquad); i++) + for (; i < ARRAY_SIZE(rgbquad); ++i) { ok(!memcmp(&rgbquad[i], &rgb_zero, sizeof(rgbquad[i])), "Got color table entry %u r=%#x g=%#x b=%#x, expected r=0 g=0 b=0.\n", @@ -8327,16 +8324,16 @@ static void test_palette_gdi(void) * but in all likelihood it is actually the system palette. */ hr = IDirectDrawSurface7_GetDC(surface, &dc); ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr); - i = GetDIBColorTable(dc, 0, sizeof(rgbquad) / sizeof(*rgbquad), rgbquad); - ok(i == sizeof(rgbquad) / sizeof(*rgbquad), "Expected count 255, got %u.\n", i); - for (i = 0; i < sizeof(expected2) / sizeof(*expected2); i++) + i = GetDIBColorTable(dc, 0, ARRAY_SIZE(rgbquad), rgbquad); + ok(i == ARRAY_SIZE(rgbquad), "Expected count 255, got %u.\n", i); + for (i = 0; i < ARRAY_SIZE(expected2); ++i) { ok(!memcmp(&rgbquad[i], &expected2[i], sizeof(rgbquad[i])), "Got color table entry %u r=%#x g=%#x b=%#x, expected r=%#x g=%#x b=%#x.\n", i, rgbquad[i].rgbRed, rgbquad[i].rgbGreen, rgbquad[i].rgbBlue, expected2[i].rgbRed, expected2[i].rgbGreen, expected2[i].rgbBlue); } - for (; i < sizeof(rgbquad) / sizeof(*rgbquad); i++) + for (; i < ARRAY_SIZE(rgbquad); ++i) { ok(!memcmp(&rgbquad[i], &rgb_zero, sizeof(rgbquad[i])), "Got color table entry %u r=%#x g=%#x b=%#x, expected r=0 g=0 b=0.\n", @@ -8367,16 +8364,16 @@ static void test_palette_gdi(void) * palette. */ hr = IDirectDrawSurface7_GetDC(surface, &dc); ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr); - i = GetDIBColorTable(dc, 0, sizeof(rgbquad) / sizeof(*rgbquad), rgbquad); - ok(i == sizeof(rgbquad) / sizeof(*rgbquad), "Expected count 255, got %u.\n", i); - for (i = 0; i < sizeof(expected3) / sizeof(*expected3); i++) + i = GetDIBColorTable(dc, 0, ARRAY_SIZE(rgbquad), rgbquad); + ok(i == ARRAY_SIZE(rgbquad), "Expected count 255, got %u.\n", i); + for (i = 0; i < ARRAY_SIZE(expected3); ++i) { ok(!memcmp(&rgbquad[i], &expected3[i], sizeof(rgbquad[i])), "Got color table entry %u r=%#x g=%#x b=%#x, expected r=%#x g=%#x b=%#x.\n", i, rgbquad[i].rgbRed, rgbquad[i].rgbGreen, rgbquad[i].rgbBlue, expected3[i].rgbRed, expected3[i].rgbGreen, expected3[i].rgbBlue); } - for (; i < sizeof(rgbquad) / sizeof(*rgbquad); i++) + for (; i < ARRAY_SIZE(rgbquad); ++i) { ok(!memcmp(&rgbquad[i], &rgb_zero, sizeof(rgbquad[i])), "Got color table entry %u r=%#x g=%#x b=%#x, expected r=0 g=0 b=0.\n", @@ -8483,7 +8480,7 @@ static void test_palette_alpha(void) ok(palette_entries[3].peFlags == 0x00, "Got unexpected peFlags 0x%02x, expected 0x00.\n", palette_entries[3].peFlags);
- for (i = 0; i < sizeof(test_data) / sizeof(*test_data); i++) + for (i = 0; i < ARRAY_SIZE(test_data); ++i) { memset(&surface_desc, 0, sizeof(surface_desc)); surface_desc.dwSize = sizeof(surface_desc); @@ -8587,7 +8584,7 @@ static void test_vb_writeonly(void) desc.dwSize = sizeof(desc); desc.dwCaps = D3DVBCAPS_WRITEONLY; desc.dwFVF = D3DFVF_XYZRHW; - desc.dwNumVertices = sizeof(quad) / sizeof(*quad); + desc.dwNumVertices = ARRAY_SIZE(quad); hr = IDirect3D7_CreateVertexBuffer(d3d, &desc, &buffer, 0); ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
@@ -8856,7 +8853,7 @@ static void test_resource_priority(void) goto done; }
- for (i = 0; i < sizeof(test_data) / sizeof(*test_data); i++) + for (i = 0; i < ARRAY_SIZE(test_data); ++i) { memset(&surface_desc, 0, sizeof(surface_desc)); surface_desc.dwSize = sizeof(surface_desc); @@ -9089,9 +9086,9 @@ static void test_fog_interpolation(void) hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_TEXTUREFACTOR, 0x000000ff); ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); i++) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { - if(!(caps.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_FOGTABLE) && tests[i].tfog) + if (!(caps.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_FOGTABLE) && tests[i].tfog) continue;
hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00808080, 0.0f, 0); @@ -9238,7 +9235,7 @@ static void test_negative_fixedfunction_fog(void) hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CLIPPING, FALSE); ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); i++) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { if (!(caps.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_FOGTABLE) && tests[i].tfog) continue; @@ -9356,7 +9353,7 @@ static void test_table_fog_zw(void) hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGTABLEMODE, D3DFOG_LINEAR); ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x000000ff, 1.0f, 0); ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); @@ -9519,7 +9516,7 @@ static void test_signed_formats(void) hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLORARG2, D3DTA_TFACTOR); ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
- for (i = 0; i < sizeof(formats) / sizeof(*formats); i++) + for (i = 0; i < ARRAY_SIZE(formats); ++i) { for (width = 1; width < 5; width += 3) { @@ -9822,7 +9819,7 @@ static void test_color_fill(void) if (!(supported_fmts & (SUPPORT_YUY2 | SUPPORT_UYVY)) || !(hal_caps.dwCaps & DDCAPS_OVERLAY)) skip("Overlays or some YUV formats not supported, skipping YUV colorfill tests.\n");
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { DWORD expected_broken = tests[i].result;
@@ -10049,7 +10046,7 @@ static void test_color_fill(void) hr = IDirectDrawSurface7_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_ROP | DDBLT_WAIT, &fx); ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
- for (i = 0; i < sizeof(rops) / sizeof(*rops); i++) + for (i = 0; i < ARRAY_SIZE(rops); ++i) { fx.dwROP = rops[i].rop; hr = IDirectDrawSurface7_Blt(surface, NULL, surface2, NULL, DDBLT_ROP | DDBLT_WAIT, &fx); @@ -10450,7 +10447,7 @@ static void test_colorkey_precision(void) memset(&lock_desc, 0, sizeof(lock_desc)); lock_desc.dwSize = sizeof(lock_desc);
- for (t = 0; t < sizeof(tests) / sizeof(*tests); ++t) + for (t = 0; t < ARRAY_SIZE(tests); ++t) { if (is_nvidia && tests[t].skip_nv) { @@ -10824,7 +10821,7 @@ static void test_shademode(void) desc.dwSize = sizeof(desc); desc.dwCaps = D3DVBCAPS_WRITEONLY; desc.dwFVF = D3DFVF_XYZ | D3DFVF_DIFFUSE; - desc.dwNumVertices = sizeof(quad_strip) / sizeof(*quad_strip); + desc.dwNumVertices = ARRAY_SIZE(quad_strip); hr = IDirect3D7_CreateVertexBuffer(d3d, &desc, &vb_strip, 0); ok(hr == D3D_OK, "Failed to create vertex buffer, hr %#x.\n", hr); hr = IDirect3DVertexBuffer7_Lock(vb_strip, 0, &data, NULL); @@ -10833,7 +10830,7 @@ static void test_shademode(void) hr = IDirect3DVertexBuffer7_Unlock(vb_strip); ok(hr == D3D_OK, "Failed to unlock vertex buffer, hr %#x.\n", hr);
- desc.dwNumVertices = sizeof(quad_list) / sizeof(*quad_list); + desc.dwNumVertices = ARRAY_SIZE(quad_list); hr = IDirect3D7_CreateVertexBuffer(d3d, &desc, &vb_list, 0); ok(hr == D3D_OK, "Failed to create vertex buffer, hr %#x.\n", hr); hr = IDirect3DVertexBuffer7_Lock(vb_list, 0, &data, NULL); @@ -10845,7 +10842,7 @@ static void test_shademode(void) /* Try it first with a TRIANGLESTRIP. Do it with different geometry because * the color fixups we have to do for FLAT shading will be dependent on that. */
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0); ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr); @@ -10949,7 +10946,7 @@ static void test_lockrect_invalid(void) goto done; }
- for (r = 0; r < sizeof(resources) / sizeof(*resources); ++r) + for (r = 0; r < ARRAY_SIZE(resources); ++r) { memset(&surface_desc, 0, sizeof(surface_desc)); surface_desc.dwSize = sizeof(surface_desc); @@ -10980,7 +10977,7 @@ static void test_lockrect_invalid(void) ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x, type %s.\n", hr, resources[r].name); */
- for (i = 0; i < sizeof(valid) / sizeof(*valid); ++i) + for (i = 0; i < ARRAY_SIZE(valid); ++i) { RECT *rect = &valid[i];
@@ -10995,7 +10992,7 @@ static void test_lockrect_invalid(void) ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, type %s.\n", hr, resources[r].name); }
- for (i = 0; i < sizeof(invalid) / sizeof(*invalid); ++i) + for (i = 0; i < ARRAY_SIZE(invalid); ++i) { RECT *rect = &invalid[i];
@@ -11408,7 +11405,7 @@ static void test_blt(void) hr = IDirectDrawSurface7_Blt(surface, NULL, rt, NULL, 0, NULL); ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
- for (i = 0; i < sizeof(test_data) / sizeof(*test_data); ++i) + for (i = 0; i < ARRAY_SIZE(test_data); ++i) { hr = IDirectDrawSurface7_Blt(surface, &test_data[i].dst_rect, surface, &test_data[i].src_rect, DDBLT_WAIT, NULL); @@ -11509,7 +11506,7 @@ static void test_blt_z_alpha(void) fx.dwAlphaSrcConstBitDepth = 8; U4(fx).dwAlphaSrcConst = 0x22;
- for (i = 0; i < sizeof(blt_flags) / sizeof(*blt_flags); ++i) + for (i = 0; i < ARRAY_SIZE(blt_flags); ++i) { fx.dwFillColor = 0x3300ff00; hr = IDirectDrawSurface7_Blt(src_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx); @@ -11692,7 +11689,7 @@ static void test_getdc(void) hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
- for (i = 0; i < (sizeof(test_data) / sizeof(*test_data)); ++i) + for (i = 0; i < ARRAY_SIZE(test_data); ++i) { memset(&surface_desc, 0, sizeof(surface_desc)); surface_desc.dwSize = sizeof(surface_desc); @@ -12411,7 +12408,7 @@ static void test_surface_desc_size(void) hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL); ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
- for (i = 0; i < sizeof(surface_caps) / sizeof(*surface_caps); ++i) + for (i = 0; i < ARRAY_SIZE(surface_caps); ++i) { memset(&surface_desc, 0, sizeof(surface_desc)); surface_desc.dwSize = sizeof(surface_desc); @@ -12430,7 +12427,7 @@ static void test_surface_desc_size(void) ok(hr == DD_OK, "Failed to query IDirectDrawSurface3, hr %#x, type %s.\n", hr, surface_caps[i].name);
/* GetSurfaceDesc() */ - for (j = 0; j < sizeof(desc_sizes) / sizeof(*desc_sizes); ++j) + for (j = 0; j < ARRAY_SIZE(desc_sizes); ++j) { memset(&desc, 0, sizeof(desc)); desc.dwSize = desc_sizes[j]; @@ -12455,7 +12452,7 @@ static void test_surface_desc_size(void) }
/* Lock() */ - for (j = 0; j < sizeof(desc_sizes) / sizeof(*desc_sizes); ++j) + for (j = 0; j < ARRAY_SIZE(desc_sizes); ++j) { const BOOL ignore_size = surface_caps[i].caps & DDSCAPS_TEXTURE && !(surface_caps[i].caps & DDSCAPS_VIDEOMEMORY); @@ -12547,7 +12544,7 @@ static void test_surface_desc_size(void) }
/* GetDisplayMode() */ - for (j = 0; j < sizeof(desc_sizes) / sizeof(*desc_sizes); ++j) + for (j = 0; j < ARRAY_SIZE(desc_sizes); ++j) { memset(&desc, 0xcc, sizeof(desc)); desc.dwSize = desc_sizes[j]; @@ -13292,7 +13289,7 @@ static void test_compute_sphere_visibility(void)
IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &identity);
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_VIEW, tests[i].view); IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, tests[i].proj);