msvcr100/test: Replace a macro with ARRAY_SIZE.

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
oldstable
Michael Stefaniuc 2018-07-05 22:07:18 +02:00 committed by Alexandre Julliard
parent 8665a60680
commit 47ba18d601
1 changed files with 20 additions and 22 deletions

View File

@ -363,8 +363,6 @@ static BOOL init(void)
return TRUE;
}
#define NUMELMS(array) (sizeof(array)/sizeof((array)[0]))
#define okwchars(dst, b0, b1, b2, b3, b4, b5, b6, b7) \
ok(dst[0] == b0 && dst[1] == b1 && dst[2] == b2 && dst[3] == b3 && \
dst[4] == b4 && dst[5] == b5 && dst[6] == b6 && dst[7] == b7, \
@ -384,7 +382,7 @@ static void test_wmemcpy_s(void)
/* Normal */
memset(dest, 'X', sizeof(dest));
ret = p_wmemcpy_s(dest, NUMELMS(dest), tiny, NUMELMS(tiny));
ret = p_wmemcpy_s(dest, ARRAY_SIZE(dest), tiny, ARRAY_SIZE(tiny));
ok(ret == 0, "Copying a buffer into a big enough destination returned %d, expected 0\n", ret);
okwchars(dest, tiny[0], tiny[1], tiny[2], tiny[3], tiny[4], tiny[5], XX, XX);
@ -392,7 +390,7 @@ static void test_wmemcpy_s(void)
errno = 0xdeadbeef;
SET_EXPECT(invalid_parameter_handler);
memset(dest, 'X', sizeof(dest));
ret = p_wmemcpy_s(dest, NUMELMS(dest), big, NUMELMS(big));
ret = p_wmemcpy_s(dest, ARRAY_SIZE(dest), big, ARRAY_SIZE(big));
ok(errno == ERANGE, "Copying a big buffer to a small destination errno %d, expected ERANGE\n", errno);
ok(ret == ERANGE, "Copying a big buffer to a small destination returned %d, expected ERANGE\n", ret);
okwchars(dest, 0, 0, 0, 0, 0, 0, 0, 0);
@ -402,7 +400,7 @@ static void test_wmemcpy_s(void)
errno = 0xdeadbeef;
SET_EXPECT(invalid_parameter_handler);
memset(dest, 'X', sizeof(dest));
ret = p_wmemcpy_s(dest, NUMELMS(dest), NULL, NUMELMS(tiny));
ret = p_wmemcpy_s(dest, ARRAY_SIZE(dest), NULL, ARRAY_SIZE(tiny));
ok(errno == EINVAL, "Copying a NULL source buffer errno %d, expected EINVAL\n", errno);
ok(ret == EINVAL, "Copying a NULL source buffer returned %d, expected EINVAL\n", ret);
okwchars(dest, 0, 0, 0, 0, 0, 0, 0, 0);
@ -412,7 +410,7 @@ static void test_wmemcpy_s(void)
errno = 0xdeadbeef;
SET_EXPECT(invalid_parameter_handler);
memset(dest, 'X', sizeof(dest));
ret = p_wmemcpy_s(dest, 0, tiny, NUMELMS(tiny));
ret = p_wmemcpy_s(dest, 0, tiny, ARRAY_SIZE(tiny));
ok(errno == ERANGE, "Copying into a destination of size 0 errno %d, expected ERANGE\n", errno);
ok(ret == ERANGE, "Copying into a destination of size 0 returned %d, expected ERANGE\n", ret);
okwchars(dest, XX, XX, XX, XX, XX, XX, XX, XX);
@ -421,7 +419,7 @@ static void test_wmemcpy_s(void)
/* Replace dest with NULL */
errno = 0xdeadbeef;
SET_EXPECT(invalid_parameter_handler);
ret = p_wmemcpy_s(NULL, NUMELMS(dest), tiny, NUMELMS(tiny));
ret = p_wmemcpy_s(NULL, ARRAY_SIZE(dest), tiny, ARRAY_SIZE(tiny));
ok(errno == EINVAL, "Copying a tiny buffer to a big NULL destination errno %d, expected EINVAL\n", errno);
ok(ret == EINVAL, "Copying a tiny buffer to a big NULL destination returned %d, expected EINVAL\n", ret);
CHECK_CALLED(invalid_parameter_handler);
@ -430,7 +428,7 @@ static void test_wmemcpy_s(void)
errno = 0xdeadbeef;
SET_EXPECT(invalid_parameter_handler);
memset(dest, 'X', sizeof(dest));
ret = p_wmemcpy_s(dest, 0, NULL, NUMELMS(tiny));
ret = p_wmemcpy_s(dest, 0, NULL, ARRAY_SIZE(tiny));
ok(errno == EINVAL, "Copying a NULL buffer into a destination of size 0 errno %d, expected EINVAL\n", errno);
ok(ret == EINVAL, "Copying a NULL buffer into a destination of size 0 returned %d, expected EINVAL\n", ret);
okwchars(dest, XX, XX, XX, XX, XX, XX, XX, XX);
@ -453,13 +451,13 @@ static void test_wmemmove_s(void)
/* Normal */
memset(dest, 'X', sizeof(dest));
ret = p_wmemmove_s(dest, NUMELMS(dest), tiny, NUMELMS(tiny));
ret = p_wmemmove_s(dest, ARRAY_SIZE(dest), tiny, ARRAY_SIZE(tiny));
ok(ret == 0, "Moving a buffer into a big enough destination returned %d, expected 0\n", ret);
okwchars(dest, tiny[0], tiny[1], tiny[2], tiny[3], tiny[4], tiny[5], XX, XX);
/* Overlapping */
memcpy(dest, big, sizeof(dest));
ret = p_wmemmove_s(dest+1, NUMELMS(dest)-1, dest, NUMELMS(dest)-1);
ret = p_wmemmove_s(dest+1, ARRAY_SIZE(dest)-1, dest, ARRAY_SIZE(dest)-1);
ok(ret == 0, "Moving a buffer up one char returned %d, expected 0\n", ret);
okwchars(dest, big[0], big[0], big[1], big[2], big[3], big[4], big[5], big[6]);
@ -467,7 +465,7 @@ static void test_wmemmove_s(void)
errno = 0xdeadbeef;
SET_EXPECT(invalid_parameter_handler);
memset(dest, 'X', sizeof(dest));
ret = p_wmemmove_s(dest, NUMELMS(dest), big, NUMELMS(big));
ret = p_wmemmove_s(dest, ARRAY_SIZE(dest), big, ARRAY_SIZE(big));
ok(errno == ERANGE, "Moving a big buffer to a small destination errno %d, expected ERANGE\n", errno);
ok(ret == ERANGE, "Moving a big buffer to a small destination returned %d, expected ERANGE\n", ret);
okwchars(dest, XX, XX, XX, XX, XX, XX, XX, XX);
@ -477,7 +475,7 @@ static void test_wmemmove_s(void)
errno = 0xdeadbeef;
SET_EXPECT(invalid_parameter_handler);
memset(dest, 'X', sizeof(dest));
ret = p_wmemmove_s(dest, NUMELMS(dest), NULL, NUMELMS(tiny));
ret = p_wmemmove_s(dest, ARRAY_SIZE(dest), NULL, ARRAY_SIZE(tiny));
ok(errno == EINVAL, "Moving a NULL source buffer errno %d, expected EINVAL\n", errno);
ok(ret == EINVAL, "Moving a NULL source buffer returned %d, expected EINVAL\n", ret);
okwchars(dest, XX, XX, XX, XX, XX, XX, XX, XX);
@ -487,7 +485,7 @@ static void test_wmemmove_s(void)
errno = 0xdeadbeef;
SET_EXPECT(invalid_parameter_handler);
memset(dest, 'X', sizeof(dest));
ret = p_wmemmove_s(dest, 0, tiny, NUMELMS(tiny));
ret = p_wmemmove_s(dest, 0, tiny, ARRAY_SIZE(tiny));
ok(errno == ERANGE, "Moving into a destination of size 0 errno %d, expected ERANGE\n", errno);
ok(ret == ERANGE, "Moving into a destination of size 0 returned %d, expected ERANGE\n", ret);
okwchars(dest, XX, XX, XX, XX, XX, XX, XX, XX);
@ -496,7 +494,7 @@ static void test_wmemmove_s(void)
/* Replace dest with NULL */
errno = 0xdeadbeef;
SET_EXPECT(invalid_parameter_handler);
ret = p_wmemmove_s(NULL, NUMELMS(dest), tiny, NUMELMS(tiny));
ret = p_wmemmove_s(NULL, ARRAY_SIZE(dest), tiny, ARRAY_SIZE(tiny));
ok(errno == EINVAL, "Moving a tiny buffer to a big NULL destination errno %d, expected EINVAL\n", errno);
ok(ret == EINVAL, "Moving a tiny buffer to a big NULL destination returned %d, expected EINVAL\n", ret);
CHECK_CALLED(invalid_parameter_handler);
@ -505,7 +503,7 @@ static void test_wmemmove_s(void)
errno = 0xdeadbeef;
SET_EXPECT(invalid_parameter_handler);
memset(dest, 'X', sizeof(dest));
ret = p_wmemmove_s(dest, 0, NULL, NUMELMS(tiny));
ret = p_wmemmove_s(dest, 0, NULL, ARRAY_SIZE(tiny));
ok(errno == EINVAL, "Moving a NULL buffer into a destination of size 0 errno %d, expected EINVAL\n", errno);
ok(ret == EINVAL, "Moving a NULL buffer into a destination of size 0 returned %d, expected EINVAL\n", ret);
okwchars(dest, XX, XX, XX, XX, XX, XX, XX, XX);
@ -824,7 +822,7 @@ static void test_event(void)
event evt;
event *evts[70];
HANDLE thread;
HANDLE threads[NUMELMS(evts)];
HANDLE threads[ARRAY_SIZE(evts)];
call_func1(p_event_ctor, &evt);
@ -851,7 +849,7 @@ static void test_event(void)
if (0) /* crashes on Windows */
p_event_wait_for_multiple(NULL, 10, TRUE, 0);
for (i = 0; i < NUMELMS(evts); i++) {
for (i = 0; i < ARRAY_SIZE(evts); i++) {
evts[i] = malloc(sizeof(evt));
call_func1(p_event_ctor, evts[i]);
}
@ -859,17 +857,17 @@ static void test_event(void)
ret = p_event_wait_for_multiple(evts, 0, TRUE, 100);
ok(!ret, "expected 0, got %d\n", ret);
ret = p_event_wait_for_multiple(evts, NUMELMS(evts), TRUE, 100);
ret = p_event_wait_for_multiple(evts, ARRAY_SIZE(evts), TRUE, 100);
ok(ret == -1, "expected -1, got %d\n", ret);
/* reset and test wait for multiple with all */
for (i = 0; i < NUMELMS(evts); i++)
for (i = 0; i < ARRAY_SIZE(evts); i++)
threads[i] = CreateThread(NULL, 0, test_event_thread, (void*)evts[i], 0, NULL);
ret = p_event_wait_for_multiple(evts, NUMELMS(evts), TRUE, 5000);
ret = p_event_wait_for_multiple(evts, ARRAY_SIZE(evts), TRUE, 5000);
ok(ret != -1, "didn't expect -1\n");
for (i = 0; i < NUMELMS(evts); i++) {
for (i = 0; i < ARRAY_SIZE(evts); i++) {
WaitForSingleObject(threads[i], INFINITE);
CloseHandle(threads[i]);
}
@ -896,7 +894,7 @@ static void test_event(void)
ret = p_event_wait_for_multiple(evts, 2, FALSE, 0);
ok(ret == 1, "expected 1, got %d\n", ret);
for (i = 0; i < NUMELMS(evts); i++) {
for (i = 0; i < ARRAY_SIZE(evts); i++) {
call_func1(p_event_dtor, evts[i]);
free(evts[i]);
}