Commit 3624b7c6 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

msvcrt/tests: Use the available ARRAY_SIZE() macro.

parent ee8acc38
...@@ -1108,7 +1108,7 @@ static void test_demangle_datatype(void) ...@@ -1108,7 +1108,7 @@ static void test_demangle_datatype(void)
{ "?AV?$CDB_GEN_BIG_ENUM_FLAG@W4CDB_WYSIWYG_BITS_ENUM@@$01@@@", "?AV?$CDB_GEN_BIG_ENUM_FLAG@W4CDB_WYSIWYG_BITS_ENUM@@$01@@@", FALSE}, { "?AV?$CDB_GEN_BIG_ENUM_FLAG@W4CDB_WYSIWYG_BITS_ENUM@@$01@@@", "?AV?$CDB_GEN_BIG_ENUM_FLAG@W4CDB_WYSIWYG_BITS_ENUM@@$01@@@", FALSE},
/* { "?AV?$CDB_GEN_BIG_ENUM_FLAG@W4CDB_WYSIWYG_BITS_ENUM@@$011@@@", "?AV?$CDB_GEN_BIG_ENUM_FLAG@W4CDB_WYSIWYG_BITS_ENUM@@$011@@@",FALSE}, */ /* { "?AV?$CDB_GEN_BIG_ENUM_FLAG@W4CDB_WYSIWYG_BITS_ENUM@@$011@@@", "?AV?$CDB_GEN_BIG_ENUM_FLAG@W4CDB_WYSIWYG_BITS_ENUM@@$011@@@",FALSE}, */
}; };
int i, num_test = (sizeof(demangle)/sizeof(struct _demangle)); int i, num_test = ARRAY_SIZE(demangle);
for (i = 0; i < num_test; i++) for (i = 0; i < num_test; i++)
{ {
...@@ -1326,7 +1326,7 @@ static void test_demangle(void) ...@@ -1326,7 +1326,7 @@ static void test_demangle(void)
/* 130 */ {"??_E?$TStrArray@$$BY0BAA@D$0BA@@@UAEPAXI@Z", /* 130 */ {"??_E?$TStrArray@$$BY0BAA@D$0BA@@@UAEPAXI@Z",
"public: virtual void * __thiscall TStrArray<char [256],16>::`vector deleting destructor'(unsigned int)"}, "public: virtual void * __thiscall TStrArray<char [256],16>::`vector deleting destructor'(unsigned int)"},
}; };
int i, num_test = (sizeof(test)/sizeof(test[0])); int i, num_test = ARRAY_SIZE(test);
char* name; char* name;
for (i = 0; i < num_test; i++) for (i = 0; i < num_test; i++)
......
...@@ -97,7 +97,7 @@ static void test_makepath(void) ...@@ -97,7 +97,7 @@ static void test_makepath(void)
unsigned int i, n; unsigned int i, n;
for (i = 0; i < sizeof(makepath_cases)/sizeof(makepath_cases[0]); ++i) for (i = 0; i < ARRAY_SIZE(makepath_cases); ++i)
{ {
const makepath_case* p = &makepath_cases[i]; const makepath_case* p = &makepath_cases[i];
...@@ -253,7 +253,7 @@ static void test_makepath_s(void) ...@@ -253,7 +253,7 @@ static void test_makepath_s(void)
ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno); ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
/* Test with the normal _makepath cases. */ /* Test with the normal _makepath cases. */
for (i = 0; i < sizeof(makepath_cases)/sizeof(makepath_cases[0]); i++) for (i = 0; i < ARRAY_SIZE(makepath_cases); i++)
{ {
const makepath_case *p = makepath_cases + i; const makepath_case *p = makepath_cases + i;
...@@ -296,7 +296,7 @@ static void test_makepath_s(void) ...@@ -296,7 +296,7 @@ static void test_makepath_s(void)
} }
/* Try insufficient length cases. */ /* Try insufficient length cases. */
for (i = 0; i < sizeof(makepath_s_cases)/sizeof(makepath_s_cases[0]); i++) for (i = 0; i < ARRAY_SIZE(makepath_s_cases); i++)
{ {
const makepath_s_case *p = makepath_s_cases + i; const makepath_s_case *p = makepath_s_cases + i;
...@@ -457,12 +457,12 @@ static void test_searchenv(void) ...@@ -457,12 +457,12 @@ static void test_searchenv(void)
ok(path_len, "GetTempPath failed\n"); ok(path_len, "GetTempPath failed\n");
memcpy(path, tmppath, path_len); memcpy(path, tmppath, path_len);
for(i=0; i<sizeof(dirs)/sizeof(*dirs); i++) { for (i=0; i<ARRAY_SIZE(dirs); i++) {
strcpy(path+path_len, dirs[i]); strcpy(path+path_len, dirs[i]);
ok(!mkdir(path), "mkdir failed (dir = %s)\n", path); ok(!mkdir(path), "mkdir failed (dir = %s)\n", path);
} }
for(i=0; i<sizeof(files)/sizeof(*files); i++) { for (i=0; i<ARRAY_SIZE(files); i++) {
strcpy(path+path_len, files[i]); strcpy(path+path_len, files[i]);
tmp_file = fopen(path, "wb"); tmp_file = fopen(path, "wb");
ok(tmp_file != NULL, "fopen failed (file = %s)\n", path); ok(tmp_file != NULL, "fopen failed (file = %s)\n", path);
...@@ -471,7 +471,7 @@ static void test_searchenv(void) ...@@ -471,7 +471,7 @@ static void test_searchenv(void)
strcpy(env1, "TEST_PATH="); strcpy(env1, "TEST_PATH=");
strcpy(env2, "TEST_PATH=;"); strcpy(env2, "TEST_PATH=;");
for(i=1; i<sizeof(dirs)/sizeof(*dirs); i++) { for (i=1; i<ARRAY_SIZE(dirs); i++) {
strcat(env1, tmppath); strcat(env1, tmppath);
strcat(env1, dirs[i]); strcat(env1, dirs[i]);
strcat(env1, ";"); strcat(env1, ";");
...@@ -599,12 +599,12 @@ static void test_searchenv(void) ...@@ -599,12 +599,12 @@ static void test_searchenv(void)
putenv("TEST_PATH="); putenv("TEST_PATH=");
for(i=sizeof(files)/sizeof(*files)-1; i>=0; i--) { for (i=ARRAY_SIZE(files)-1; i>=0; i--) {
strcpy(path+path_len, files[i]); strcpy(path+path_len, files[i]);
ok(!remove(path), "remove failed (file = %s)\n", path); ok(!remove(path), "remove failed (file = %s)\n", path);
} }
for(i=sizeof(dirs)/sizeof(*dirs)-1; i>=0; i--) { for (i=ARRAY_SIZE(dirs)-1; i>=0; i--) {
strcpy(path+path_len, dirs[i]); strcpy(path+path_len, dirs[i]);
ok(!rmdir(path), "rmdir failed (dir = %s)\n", path); ok(!rmdir(path), "rmdir failed (dir = %s)\n", path);
} }
......
...@@ -144,7 +144,7 @@ static void test_fileops( void ) ...@@ -144,7 +144,7 @@ static void test_fileops( void )
write (fd, outbuffer, sizeof (outbuffer)); write (fd, outbuffer, sizeof (outbuffer));
close (fd); close (fd);
for (bufmode=0; bufmode < sizeof(bufmodes)/sizeof(bufmodes[0]); bufmode++) for (bufmode=0; bufmode < ARRAY_SIZE(bufmodes); bufmode++)
{ {
fd = open ("fdopen.tst", O_RDONLY | O_BINARY); fd = open ("fdopen.tst", O_RDONLY | O_BINARY);
file = fdopen (fd, "rb"); file = fdopen (fd, "rb");
...@@ -195,13 +195,13 @@ static void test_fileops( void ) ...@@ -195,13 +195,13 @@ static void test_fileops( void )
} }
fd = open ("fdopen.tst", O_RDONLY | O_TEXT); fd = open ("fdopen.tst", O_RDONLY | O_TEXT);
file = fdopen (fd, "rt"); /* open in TEXT mode */ file = fdopen (fd, "rt"); /* open in TEXT mode */
ok(fgetws(wbuffer,sizeof(wbuffer)/sizeof(wbuffer[0]),file) !=0,"fgetws failed unexpected\n"); ok(fgetws(wbuffer,ARRAY_SIZE(wbuffer),file) !=0,"fgetws failed unexpected\n");
ok(fgetws(wbuffer,sizeof(wbuffer)/sizeof(wbuffer[0]),file) ==0,"fgetws didn't signal EOF\n"); ok(fgetws(wbuffer,ARRAY_SIZE(wbuffer),file) ==0,"fgetws didn't signal EOF\n");
ok(feof(file) !=0,"feof doesn't signal EOF\n"); ok(feof(file) !=0,"feof doesn't signal EOF\n");
rewind(file); rewind(file);
ok(fgetws(wbuffer,strlen(outbuffer),file) !=0,"fgetws failed unexpected\n"); ok(fgetws(wbuffer,strlen(outbuffer),file) !=0,"fgetws failed unexpected\n");
ok(lstrlenW(wbuffer) == (lstrlenA(outbuffer) -1),"fgetws didn't read right size\n"); ok(lstrlenW(wbuffer) == (lstrlenA(outbuffer) -1),"fgetws didn't read right size\n");
ok(fgetws(wbuffer,sizeof(outbuffer)/sizeof(outbuffer[0]),file) !=0,"fgets failed unexpected\n"); ok(fgetws(wbuffer,ARRAY_SIZE(outbuffer),file) !=0,"fgets failed unexpected\n");
ok(lstrlenW(wbuffer) == 1,"fgets dropped chars\n"); ok(lstrlenW(wbuffer) == 1,"fgets dropped chars\n");
fclose (file); fclose (file);
...@@ -624,7 +624,7 @@ static void test_flsbuf( void ) ...@@ -624,7 +624,7 @@ static void test_flsbuf( void )
static const int bufmodes[] = {_IOFBF,_IONBF}; static const int bufmodes[] = {_IOFBF,_IONBF};
tempf=_tempnam(".","wne"); tempf=_tempnam(".","wne");
for (bufmode=0; bufmode < sizeof(bufmodes)/sizeof(bufmodes[0]); bufmode++) for (bufmode=0; bufmode < ARRAY_SIZE(bufmodes); bufmode++)
{ {
tempfh = fopen(tempf,"wb"); tempfh = fopen(tempf,"wb");
setvbuf(tempfh,NULL,bufmodes[bufmode],2048); setvbuf(tempfh,NULL,bufmodes[bufmode],2048);
...@@ -878,8 +878,7 @@ static void test_fgetwc_locale(const char* text, const char* locale, int codepag ...@@ -878,8 +878,7 @@ static void test_fgetwc_locale(const char* text, const char* locale, int codepag
{ {
/* mbstowcs rejects invalid multibyte sequence, /* mbstowcs rejects invalid multibyte sequence,
so we use MultiByteToWideChar here. */ so we use MultiByteToWideChar here. */
ret = MultiByteToWideChar(codepage, 0, text, -1, ret = MultiByteToWideChar(codepage, 0, text, -1, wtextW, ARRAY_SIZE(wtextW));
wtextW, sizeof(wtextW)/sizeof(wtextW[0]));
ok(ret > 0, "MultiByteToWideChar failed\n"); ok(ret > 0, "MultiByteToWideChar failed\n");
} }
else else
...@@ -910,7 +909,7 @@ static void test_fgetwc_locale(const char* text, const char* locale, int codepag ...@@ -910,7 +909,7 @@ static void test_fgetwc_locale(const char* text, const char* locale, int codepag
tempfh = fopen(tempfile, "rb"); tempfh = fopen(tempfile, "rb");
ok(tempfh != NULL, "can't open tempfile\n"); ok(tempfh != NULL, "can't open tempfile\n");
for (i = 0; i < sizeof(wchar_text)/sizeof(wchar_text[0]); i++) for (i = 0; i < ARRAY_SIZE(wchar_text); i++)
{ {
ch = fgetwc(tempfh); ch = fgetwc(tempfh);
ok(ch == wchar_text[i], "got %04hx, expected %04x (cp%d[%d])\n", ch, wchar_text[i], codepage, i); ok(ch == wchar_text[i], "got %04hx, expected %04x (cp%d[%d])\n", ch, wchar_text[i], codepage, i);
...@@ -946,7 +945,7 @@ static void test_fgetwc_unicode(void) ...@@ -946,7 +945,7 @@ static void test_fgetwc_unicode(void)
tempfh = fopen(tempfile, "rt,ccs=unicode"); tempfh = fopen(tempfile, "rt,ccs=unicode");
ok(tempfh != NULL, "can't open tempfile\n"); ok(tempfh != NULL, "can't open tempfile\n");
for (i = 1; i < sizeof(wchar_text)/sizeof(wchar_text[0]); i++) for (i = 1; i < ARRAY_SIZE(wchar_text); i++)
{ {
ch = fgetwc(tempfh); ch = fgetwc(tempfh);
ok(ch == wchar_text[i], ok(ch == wchar_text[i],
...@@ -958,7 +957,7 @@ static void test_fgetwc_unicode(void) ...@@ -958,7 +957,7 @@ static void test_fgetwc_unicode(void)
tempfh = fopen(tempfile, "wb"); tempfh = fopen(tempfile, "wb");
ok(tempfh != NULL, "can't open tempfile\n"); ok(tempfh != NULL, "can't open tempfile\n");
ret = WideCharToMultiByte(CP_UTF8, 0, wchar_text, sizeof(wchar_text)/sizeof(wchar_text[0]), ret = WideCharToMultiByte(CP_UTF8, 0, wchar_text, ARRAY_SIZE(wchar_text),
utf8_text, sizeof(utf8_text), NULL, NULL); utf8_text, sizeof(utf8_text), NULL, NULL);
ok(ret > 0, "utf-8 conversion failed\n"); ok(ret > 0, "utf-8 conversion failed\n");
fwrite(utf8_text, sizeof(char), ret, tempfh); fwrite(utf8_text, sizeof(char), ret, tempfh);
...@@ -966,7 +965,7 @@ static void test_fgetwc_unicode(void) ...@@ -966,7 +965,7 @@ static void test_fgetwc_unicode(void)
tempfh = fopen(tempfile, "rt, ccs=UTF-8"); tempfh = fopen(tempfile, "rt, ccs=UTF-8");
ok(tempfh != NULL, "can't open tempfile\n"); ok(tempfh != NULL, "can't open tempfile\n");
for (i = 1; i < sizeof(wchar_text)/sizeof(wchar_text[0]); i++) for (i = 1; i < ARRAY_SIZE(wchar_text); i++)
{ {
ch = fgetwc(tempfh); ch = fgetwc(tempfh);
ok(ch == wchar_text[i], ok(ch == wchar_text[i],
...@@ -2659,5 +2658,5 @@ START_TEST(file) ...@@ -2659,5 +2658,5 @@ START_TEST(file)
/* Wait for the (_P_NOWAIT) spawned processes to finish to make sure the report /* Wait for the (_P_NOWAIT) spawned processes to finish to make sure the report
* file contains lines in the correct order * file contains lines in the correct order
*/ */
WaitForMultipleObjects(sizeof(proc_handles)/sizeof(proc_handles[0]), proc_handles, TRUE, 5000); WaitForMultipleObjects(ARRAY_SIZE(proc_handles), proc_handles, TRUE, 5000);
} }
...@@ -643,7 +643,7 @@ static void test_crtGetStringTypeW(void) ...@@ -643,7 +643,7 @@ static void test_crtGetStringTypeW(void)
return; return;
} }
for(i=0; i<sizeof(str)/sizeof(*str); i++) { for(i=0; i<ARRAY_SIZE(str); i++) {
ret_crt = p__crtGetStringTypeW(0, CT_CTYPE1, str[i], 1, &out_crt); ret_crt = p__crtGetStringTypeW(0, CT_CTYPE1, str[i], 1, &out_crt);
ret = GetStringTypeW(CT_CTYPE1, str[i], 1, &out); ret = GetStringTypeW(CT_CTYPE1, str[i], 1, &out);
ok(ret == ret_crt, "%d) ret_crt = %d\n", i, (int)ret_crt); ok(ret == ret_crt, "%d) ret_crt = %d\n", i, (int)ret_crt);
...@@ -708,7 +708,7 @@ static void test__Gettnames(void) ...@@ -708,7 +708,7 @@ static void test__Gettnames(void)
else else
ok(size==0x164 || broken(size==0xb8), "structure size: %x\n", size); ok(size==0x164 || broken(size==0xb8), "structure size: %x\n", size);
for (i = 0; i < sizeof(time_data)/sizeof(time_data[0]); i++) for (i = 0; i < ARRAY_SIZE(time_data); i++)
{ {
size = GetLocaleInfoA(MAKELCID(LANG_ENGLISH, SORT_DEFAULT), size = GetLocaleInfoA(MAKELCID(LANG_ENGLISH, SORT_DEFAULT),
time_data[i], buf, sizeof(buf)); time_data[i], buf, sizeof(buf));
...@@ -722,7 +722,7 @@ static void test__Gettnames(void) ...@@ -722,7 +722,7 @@ static void test__Gettnames(void)
return; return;
ret = _Gettnames(); ret = _Gettnames();
for (i = 0; i < sizeof(time_data)/sizeof(time_data[0]); i++) for (i = 0; i < ARRAY_SIZE(time_data); i++)
{ {
size = GetLocaleInfoA(MAKELCID(LANG_GERMAN, SORT_DEFAULT), size = GetLocaleInfoA(MAKELCID(LANG_GERMAN, SORT_DEFAULT),
time_data[i], buf, sizeof(buf)); time_data[i], buf, sizeof(buf));
......
...@@ -164,7 +164,7 @@ static void test_I10_OUTPUT(void) ...@@ -164,7 +164,7 @@ static void test_I10_OUTPUT(void)
if (j != 12) if (j != 12)
trace("sizeof(long double) = %d on this machine\n", j); trace("sizeof(long double) = %d on this machine\n", j);
for(i=0; i<sizeof(I10_OUTPUT_tests)/sizeof(I10_OUTPUT_test); i++) { for(i=0; i<ARRAY_SIZE(I10_OUTPUT_tests); i++) {
memset(out.str, '#', sizeof(out.str)); memset(out.str, '#', sizeof(out.str));
if (sizeof(long double) == 12) if (sizeof(long double) == 12)
...@@ -621,7 +621,7 @@ static void test__lfind_s(void) ...@@ -621,7 +621,7 @@ static void test__lfind_s(void)
} }
key = 1234; key = 1234;
num = sizeof(tests)/sizeof(tests[0]); num = ARRAY_SIZE(tests);
errno = 0xdeadbeef; errno = 0xdeadbeef;
found = p_lfind_s(NULL, tests, &num, sizeof(int), _lfind_s_comp, NULL); found = p_lfind_s(NULL, tests, &num, sizeof(int), _lfind_s_comp, NULL);
......
...@@ -841,7 +841,7 @@ static void test_snprintf (void) ...@@ -841,7 +841,7 @@ static void test_snprintf (void)
const int bufsiz = sizeof buffer; const int bufsiz = sizeof buffer;
unsigned int i; unsigned int i;
for (i = 0; i < sizeof tests / sizeof tests[0]; i++) { for (i = 0; i < ARRAY_SIZE(tests); i++) {
const char *fmt = tests[i].format; const char *fmt = tests[i].format;
const int expect = tests[i].expected; const int expect = tests[i].expected;
const int n = _snprintf (buffer, bufsiz, fmt); const int n = _snprintf (buffer, bufsiz, fmt);
...@@ -1215,7 +1215,7 @@ static void test_vsnwprintf(void) ...@@ -1215,7 +1215,7 @@ static void test_vsnwprintf(void)
wchar_t str[32]; wchar_t str[32];
char buf[32]; char buf[32];
ret = _vsnwprintf_wrapper( str, sizeof(str)/sizeof(str[0]), format, one, two, three ); ret = _vsnwprintf_wrapper( str, ARRAY_SIZE(str), format, one, two, three );
ok( ret == 11, "got %d expected 11\n", ret ); ok( ret == 11, "got %d expected 11\n", ret );
WideCharToMultiByte( CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL ); WideCharToMultiByte( CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL );
......
...@@ -1014,7 +1014,7 @@ static void test_wcscpy_s(void) ...@@ -1014,7 +1014,7 @@ static void test_wcscpy_s(void)
return; return;
} }
ret = p_wcsncpy_s(NULL, 18, szLongText, sizeof(szLongText)/sizeof(WCHAR)); ret = p_wcsncpy_s(NULL, 18, szLongText, ARRAY_SIZE(szLongText));
ok(ret == EINVAL, "p_wcsncpy_s expect EINVAL got %d\n", ret); ok(ret == EINVAL, "p_wcsncpy_s expect EINVAL got %d\n", ret);
szDest[0] = 'A'; szDest[0] = 'A';
...@@ -1028,16 +1028,16 @@ static void test_wcscpy_s(void) ...@@ -1028,16 +1028,16 @@ static void test_wcscpy_s(void)
ok(szDest[0] == 0, "szDest[0] not 0\n"); ok(szDest[0] == 0, "szDest[0] not 0\n");
szDest[0] = 'A'; szDest[0] = 'A';
ret = p_wcsncpy_s(szDest, 0, szLongText, sizeof(szLongText)/sizeof(WCHAR)); ret = p_wcsncpy_s(szDest, 0, szLongText, ARRAY_SIZE(szLongText));
ok(ret == ERANGE || ret == EINVAL, "expected ERANGE/EINVAL got %d\n", ret); ok(ret == ERANGE || ret == EINVAL, "expected ERANGE/EINVAL got %d\n", ret);
ok(szDest[0] == 0 || ret == EINVAL, "szDest[0] not 0\n"); ok(szDest[0] == 0 || ret == EINVAL, "szDest[0] not 0\n");
ret = p_wcsncpy_s(szDest, 18, szLongText, sizeof(szLongText)/sizeof(WCHAR)); ret = p_wcsncpy_s(szDest, 18, szLongText, ARRAY_SIZE(szLongText));
ok(ret == 0, "expected 0 got %d\n", ret); ok(ret == 0, "expected 0 got %d\n", ret);
ok(lstrcmpW(szDest, szLongText) == 0, "szDest != szLongText\n"); ok(lstrcmpW(szDest, szLongText) == 0, "szDest != szLongText\n");
szDest[0] = 'A'; szDest[0] = 'A';
ret = p_wcsncpy_s(szDestShort, 8, szLongText, sizeof(szLongText)/sizeof(WCHAR)); ret = p_wcsncpy_s(szDestShort, 8, szLongText, ARRAY_SIZE(szLongText));
ok(ret == ERANGE || ret == EINVAL, "expected ERANGE/EINVAL got %d\n", ret); ok(ret == ERANGE || ret == EINVAL, "expected ERANGE/EINVAL got %d\n", ret);
ok(szDestShort[0] == 0, "szDestShort[0] not 0\n"); ok(szDestShort[0] == 0, "szDestShort[0] not 0\n");
...@@ -1065,7 +1065,7 @@ static void test__wcsupr_s(void) ...@@ -1065,7 +1065,7 @@ static void test__wcsupr_s(void)
static const WCHAR expectedString[] = {'M', 'I', 'X', 'E', 'D', 'L', 'O', static const WCHAR expectedString[] = {'M', 'I', 'X', 'E', 'D', 'L', 'O',
'W', 'E', 'R', 'U', 'P', 'P', 'E', 'W', 'E', 'R', 'U', 'P', 'P', 'E',
'R', 0}; 'R', 0};
WCHAR testBuffer[2*sizeof(mixedString)/sizeof(WCHAR)]; WCHAR testBuffer[2*ARRAY_SIZE(mixedString)];
int ret; int ret;
if (!p_wcsupr_s) if (!p_wcsupr_s)
...@@ -1082,7 +1082,7 @@ static void test__wcsupr_s(void) ...@@ -1082,7 +1082,7 @@ static void test__wcsupr_s(void)
/* Test NULL input string and valid size. */ /* Test NULL input string and valid size. */
errno = EBADF; errno = EBADF;
ret = p_wcsupr_s(NULL, sizeof(testBuffer)/sizeof(WCHAR)); ret = p_wcsupr_s(NULL, ARRAY_SIZE(testBuffer));
ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret); ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno); ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
...@@ -1126,21 +1126,21 @@ static void test__wcsupr_s(void) ...@@ -1126,21 +1126,21 @@ static void test__wcsupr_s(void)
/* Test normal string uppercasing. */ /* Test normal string uppercasing. */
wcscpy(testBuffer, mixedString); wcscpy(testBuffer, mixedString);
ret = p_wcsupr_s(testBuffer, sizeof(mixedString)/sizeof(WCHAR)); ret = p_wcsupr_s(testBuffer, ARRAY_SIZE(mixedString));
ok(ret == 0, "Expected _wcsupr_s to succeed, got %d\n", ret); ok(ret == 0, "Expected _wcsupr_s to succeed, got %d\n", ret);
ok(!wcscmp(testBuffer, expectedString), "Expected the string to be fully upper-case\n"); ok(!wcscmp(testBuffer, expectedString), "Expected the string to be fully upper-case\n");
/* Test uppercasing with a shorter buffer size count. */ /* Test uppercasing with a shorter buffer size count. */
wcscpy(testBuffer, mixedString); wcscpy(testBuffer, mixedString);
errno = EBADF; errno = EBADF;
ret = p_wcsupr_s(testBuffer, sizeof(mixedString)/sizeof(WCHAR) - 1); ret = p_wcsupr_s(testBuffer, ARRAY_SIZE(mixedString) - 1);
ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret); ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno); ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
ok(testBuffer[0] == '\0', "Expected the first buffer character to be null\n"); ok(testBuffer[0] == '\0', "Expected the first buffer character to be null\n");
/* Test uppercasing with a longer buffer size count. */ /* Test uppercasing with a longer buffer size count. */
wcscpy(testBuffer, mixedString); wcscpy(testBuffer, mixedString);
ret = p_wcsupr_s(testBuffer, sizeof(testBuffer)/sizeof(WCHAR)); ret = p_wcsupr_s(testBuffer, ARRAY_SIZE(testBuffer));
ok(ret == 0, "Expected _wcsupr_s to succeed, got %d\n", ret); ok(ret == 0, "Expected _wcsupr_s to succeed, got %d\n", ret);
ok(!wcscmp(testBuffer, expectedString), "Expected the string to be fully upper-case\n"); ok(!wcscmp(testBuffer, expectedString), "Expected the string to be fully upper-case\n");
} }
...@@ -1152,7 +1152,7 @@ static void test__wcslwr_s(void) ...@@ -1152,7 +1152,7 @@ static void test__wcslwr_s(void)
static const WCHAR expectedString[] = {'m', 'i', 'x', 'e', 'd', 'l', 'o', static const WCHAR expectedString[] = {'m', 'i', 'x', 'e', 'd', 'l', 'o',
'w', 'e', 'r', 'u', 'p', 'p', 'e', 'w', 'e', 'r', 'u', 'p', 'p', 'e',
'r', 0}; 'r', 0};
WCHAR buffer[2*sizeof(mixedString)/sizeof(WCHAR)]; WCHAR buffer[2*ARRAY_SIZE(mixedString)];
int ret; int ret;
if (!p_wcslwr_s) if (!p_wcslwr_s)
...@@ -1169,7 +1169,7 @@ static void test__wcslwr_s(void) ...@@ -1169,7 +1169,7 @@ static void test__wcslwr_s(void)
/* Test NULL input string and valid size. */ /* Test NULL input string and valid size. */
errno = EBADF; errno = EBADF;
ret = p_wcslwr_s(NULL, sizeof(buffer)/sizeof(buffer[0])); ret = p_wcslwr_s(NULL, ARRAY_SIZE(buffer));
ok(ret == EINVAL, "expected EINVAL, got %d\n", ret); ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
ok(errno == EINVAL, "expected errno EINVAL, got %d\n", errno); ok(errno == EINVAL, "expected errno EINVAL, got %d\n", errno);
...@@ -1213,21 +1213,21 @@ static void test__wcslwr_s(void) ...@@ -1213,21 +1213,21 @@ static void test__wcslwr_s(void)
/* Test normal string uppercasing. */ /* Test normal string uppercasing. */
wcscpy(buffer, mixedString); wcscpy(buffer, mixedString);
ret = p_wcslwr_s(buffer, sizeof(mixedString)/sizeof(WCHAR)); ret = p_wcslwr_s(buffer, ARRAY_SIZE(mixedString));
ok(ret == 0, "expected 0, got %d\n", ret); ok(ret == 0, "expected 0, got %d\n", ret);
ok(!wcscmp(buffer, expectedString), "expected lowercase\n"); ok(!wcscmp(buffer, expectedString), "expected lowercase\n");
/* Test uppercasing with a shorter buffer size count. */ /* Test uppercasing with a shorter buffer size count. */
wcscpy(buffer, mixedString); wcscpy(buffer, mixedString);
errno = EBADF; errno = EBADF;
ret = p_wcslwr_s(buffer, sizeof(mixedString)/sizeof(WCHAR) - 1); ret = p_wcslwr_s(buffer, ARRAY_SIZE(mixedString) - 1);
ok(ret == EINVAL, "expected EINVAL, got %d\n", ret); ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
ok(errno == EINVAL, "expected errno to be EINVAL, got %d\n", errno); ok(errno == EINVAL, "expected errno to be EINVAL, got %d\n", errno);
ok(buffer[0] == '\0', "expected empty string\n"); ok(buffer[0] == '\0', "expected empty string\n");
/* Test uppercasing with a longer buffer size count. */ /* Test uppercasing with a longer buffer size count. */
wcscpy(buffer, mixedString); wcscpy(buffer, mixedString);
ret = p_wcslwr_s(buffer, sizeof(buffer)/sizeof(WCHAR)); ret = p_wcslwr_s(buffer, ARRAY_SIZE(buffer));
ok(ret == 0, "expected 0, got %d\n", ret); ok(ret == 0, "expected 0, got %d\n", ret);
ok(!wcscmp(buffer, expectedString), "expected lowercase\n"); ok(!wcscmp(buffer, expectedString), "expected lowercase\n");
} }
...@@ -1243,7 +1243,7 @@ static void test_mbcjisjms(void) ...@@ -1243,7 +1243,7 @@ static void test_mbcjisjms(void)
unsigned int i, j; unsigned int i, j;
int prev_cp = _getmbcp(); int prev_cp = _getmbcp();
for (i = 0; i < sizeof(cp)/sizeof(cp[0]); i++) for (i = 0; i < ARRAY_SIZE(cp); i++)
{ {
_setmbcp(cp[i]); _setmbcp(cp[i]);
for (j = 0; jisjms[j][0] != 0; j++) for (j = 0; jisjms[j][0] != 0; j++)
...@@ -1271,7 +1271,7 @@ static void test_mbcjmsjis(void) ...@@ -1271,7 +1271,7 @@ static void test_mbcjmsjis(void)
unsigned int i, j; unsigned int i, j;
int prev_cp = _getmbcp(); int prev_cp = _getmbcp();
for (i = 0; i < sizeof(cp)/sizeof(cp[0]); i++) for (i = 0; i < ARRAY_SIZE(cp); i++)
{ {
_setmbcp(cp[i]); _setmbcp(cp[i]);
for (j = 0; jmsjis[j][0] != 0; j++) for (j = 0; jmsjis[j][0] != 0; j++)
...@@ -1298,7 +1298,7 @@ static void test_mbctohira(void) ...@@ -1298,7 +1298,7 @@ static void test_mbctohira(void)
unsigned int prev_cp = _getmbcp(); unsigned int prev_cp = _getmbcp();
_setmbcp(_MB_CP_SBCS); _setmbcp(_MB_CP_SBCS);
for (i = 0; i < sizeof(mbchira_932)/sizeof(mbchira_932[0]); i++) for (i = 0; i < ARRAY_SIZE(mbchira_932); i++)
{ {
int ret, exp = mbchira_932[i][0]; int ret, exp = mbchira_932[i][0];
ret = _mbctohira(mbchira_932[i][0]); ret = _mbctohira(mbchira_932[i][0]);
...@@ -1306,7 +1306,7 @@ static void test_mbctohira(void) ...@@ -1306,7 +1306,7 @@ static void test_mbctohira(void)
} }
_setmbcp(932); _setmbcp(932);
for (i = 0; i < sizeof(mbchira_932)/sizeof(mbchira_932[0]); i++) for (i = 0; i < ARRAY_SIZE(mbchira_932); i++)
{ {
unsigned int ret, exp; unsigned int ret, exp;
ret = _mbctohira(mbchira_932[i][0]); ret = _mbctohira(mbchira_932[i][0]);
...@@ -1327,7 +1327,7 @@ static void test_mbctokata(void) ...@@ -1327,7 +1327,7 @@ static void test_mbctokata(void)
unsigned int prev_cp = _getmbcp(); unsigned int prev_cp = _getmbcp();
_setmbcp(_MB_CP_SBCS); _setmbcp(_MB_CP_SBCS);
for (i = 0; i < sizeof(mbckata_932)/sizeof(mbckata_932[0]); i++) for (i = 0; i < ARRAY_SIZE(mbckata_932); i++)
{ {
int ret, exp = mbckata_932[i][0]; int ret, exp = mbckata_932[i][0];
ret = _mbctokata(mbckata_932[i][0]); ret = _mbctokata(mbckata_932[i][0]);
...@@ -1335,7 +1335,7 @@ static void test_mbctokata(void) ...@@ -1335,7 +1335,7 @@ static void test_mbctokata(void)
} }
_setmbcp(932); _setmbcp(932);
for (i = 0; i < sizeof(mbckata_932)/sizeof(mbckata_932[0]); i++) for (i = 0; i < ARRAY_SIZE(mbckata_932); i++)
{ {
unsigned int ret, exp; unsigned int ret, exp;
ret = _mbctokata(mbckata_932[i][0]); ret = _mbctokata(mbckata_932[i][0]);
...@@ -1356,7 +1356,7 @@ static void test_mbbtombc(void) ...@@ -1356,7 +1356,7 @@ static void test_mbbtombc(void)
int i, j; int i, j;
int prev_cp = _getmbcp(); int prev_cp = _getmbcp();
for (i = 0; i < sizeof(cp)/sizeof(cp[0]); i++) for (i = 0; i < ARRAY_SIZE(cp); i++)
{ {
_setmbcp(cp[i]); _setmbcp(cp[i]);
for (j = 0; mbbmbc[j][0] != 0; j++) for (j = 0; mbbmbc[j][0] != 0; j++)
...@@ -1409,13 +1409,13 @@ static void test_ismbckata(void) { ...@@ -1409,13 +1409,13 @@ static void test_ismbckata(void) {
unsigned int i; unsigned int i;
_setmbcp(_MB_CP_SBCS); _setmbcp(_MB_CP_SBCS);
for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) { for (i = 0; i < ARRAY_SIZE(tests); i++) {
ret = _ismbckata(tests[i].c); ret = _ismbckata(tests[i].c);
ok(!ret, "expected 0, got %d for %04x\n", ret, tests[i].c); ok(!ret, "expected 0, got %d for %04x\n", ret, tests[i].c);
} }
_setmbcp(932); _setmbcp(932);
for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) { for (i = 0; i < ARRAY_SIZE(tests); i++) {
ret = _ismbckata(tests[i].c); ret = _ismbckata(tests[i].c);
ok(!!ret == tests[i].exp, "expected %d, got %d for %04x\n", ok(!!ret == tests[i].exp, "expected %d, got %d for %04x\n",
tests[i].exp, !!ret, tests[i].c); tests[i].exp, !!ret, tests[i].c);
...@@ -2993,7 +2993,7 @@ static void test__wcstoi64(void) ...@@ -2993,7 +2993,7 @@ static void test__wcstoi64(void)
ok(ures == 071, "ures != 071\n"); ok(ures == 071, "ures != 071\n");
/* Test various unicode digits */ /* Test various unicode digits */
for (i = 0; i < sizeof(zeros) / sizeof(zeros[0]); ++i) { for (i = 0; i < ARRAY_SIZE(zeros); ++i) {
WCHAR tmp[] = {zeros[i] + 4, zeros[i], zeros[i] + 5, 0}; WCHAR tmp[] = {zeros[i] + 4, zeros[i], zeros[i] + 5, 0};
res = p_wcstoi64(tmp, NULL, 0); res = p_wcstoi64(tmp, NULL, 0);
ok(res == 405, "with zero = U+%04X: got %d, expected 405\n", zeros[i], (int)res); ok(res == 405, "with zero = U+%04X: got %d, expected 405\n", zeros[i], (int)res);
......
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