Commit 3f9857ae authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

d3d9/tests: Use ARRAY_SIZE() macro.

parent 1c5c5507
......@@ -26,6 +26,8 @@
#include <initguid.h>
#include <d3d9.h>
#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
static HMODULE d3d9_handle = 0;
static DEVMODEW registry_mode;
......@@ -697,7 +699,7 @@ static void test_create_depth_stencil_surface_ex(void)
warp = adapter_is_warp(&identifier);
IDirect3D9_Release(d3d);
for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
surface = (IDirect3DSurface9 *)0xdeadbeef;
hr = IDirect3DDevice9Ex_CreateDepthStencilSurfaceEx(device, 64, 64, D3DFMT_D24S8,
......@@ -2809,7 +2811,7 @@ static void test_wndproc(void)
memset(&devmode, 0, sizeof(devmode));
devmode.dmSize = sizeof(devmode);
for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
devmode.dmPelsWidth = user32_width;
......@@ -3424,7 +3426,7 @@ static void test_window_style(void)
SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
focus_window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW | tests[i].style_flags,
0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
......@@ -3668,7 +3670,7 @@ static void test_swapchain_parameters(void)
mode.Format = D3DFMT_X8R8G8B8;
mode.ScanLineOrdering = 0;
for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
memset(&present_parameters, 0, sizeof(present_parameters));
present_parameters.BackBufferWidth = registry_mode.dmPelsWidth;
......
......@@ -12290,7 +12290,7 @@ static void test_stretch_rect(void)
ok(hr == D3D_OK, "Failed to get caps, hr %#x.\n", hr);
can_stretch_textures = caps.DevCaps2 & D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES;
for (i = 0; i < sizeof(formats) / sizeof(*formats); ++i)
for (i = 0; i < ARRAY_SIZE(formats); ++i)
{
src_format = formats[i];
if (FAILED(IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
......@@ -12302,7 +12302,7 @@ static void test_stretch_rect(void)
continue;
}
for (j = 0; j < sizeof(formats) / sizeof(*formats); ++j)
for (j = 0; j < ARRAY_SIZE(formats); ++j)
{
dst_format = formats[j];
if (FAILED(IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
......
......@@ -21,6 +21,8 @@
#include <d3d9.h>
#include "wine/test.h"
#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
static DWORD texture_stages;
/* ============================ State Testing Framework ========================== */
......@@ -1190,7 +1192,7 @@ const D3DRENDERSTATETYPE render_state_indices[] =
struct render_state_data
{
DWORD states[sizeof(render_state_indices) / sizeof(*render_state_indices)];
DWORD states[ARRAY_SIZE(render_state_indices)];
};
struct render_state_arg
......@@ -1214,7 +1216,7 @@ static void render_state_apply_data(IDirect3DDevice9 *device, const struct state
HRESULT hret;
unsigned int i;
for (i = 0; i < sizeof(render_state_indices) / sizeof(*render_state_indices); ++i)
for (i = 0; i < ARRAY_SIZE(render_state_indices); ++i)
{
hret = IDirect3DDevice9_SetRenderState(device, render_state_indices[i], rsdata->states[i]);
ok(hret == D3D_OK, "SetRenderState returned %#x.\n", hret);
......@@ -1229,7 +1231,7 @@ static void render_state_check_data(IDirect3DDevice9 *device, const struct state
unsigned int i;
HRESULT hr;
for (i = 0; i < sizeof(render_state_indices) / sizeof(*render_state_indices); ++i)
for (i = 0; i < ARRAY_SIZE(render_state_indices); ++i)
{
DWORD value = ctx->poison_data_buffer.states[i];
hr = IDirect3DDevice9_GetRenderState(device, render_state_indices[i], &value);
......@@ -1359,7 +1361,7 @@ static void render_state_poison_data_init(struct render_state_data *data)
{
unsigned int i;
for (i = 0; i < sizeof(render_state_indices) / sizeof(*render_state_indices); ++i)
for (i = 0; i < ARRAY_SIZE(render_state_indices); ++i)
{
data->states[i] = 0x1337c0de;
}
......@@ -1608,10 +1610,10 @@ static HRESULT render_state_test_init(IDirect3DDevice9 *device, struct state_tes
render_state_test_data_init(&ctx->test_data_all_buffer);
render_state_poison_data_init(&ctx->poison_data_buffer);
for (i = 0; i < sizeof(render_state_indices) / sizeof(*render_state_indices); ++i)
for (i = 0; i < ARRAY_SIZE(render_state_indices); ++i)
{
ctx->test_data_vertex_buffer.states[i] = ctx->default_data_buffer.states[i];
for (j = 0; j < sizeof(states_vertex) / sizeof(*states_vertex); ++j)
for (j = 0; j < ARRAY_SIZE(states_vertex); ++j)
{
if (render_state_indices[i] == states_vertex[j])
{
......@@ -1621,7 +1623,7 @@ static HRESULT render_state_test_init(IDirect3DDevice9 *device, struct state_tes
}
ctx->test_data_pixel_buffer.states[i] = ctx->default_data_buffer.states[i];
for (j = 0; j < sizeof(states_pixel) / sizeof(*states_pixel); ++j)
for (j = 0; j < ARRAY_SIZE(states_pixel); ++j)
{
if (render_state_indices[i] == states_pixel[j])
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment