Commit 207e70cd authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

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

parent f7c2fe87
......@@ -128,7 +128,7 @@ static void testBinaryToStringA(void)
ret = CryptBinaryToStringA(NULL, 0, 0, NULL, &strLen);
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
for (i = 0; i < ARRAY_SIZE(tests); i++)
{
DWORD strLen = 0;
LPSTR str = NULL;
......@@ -163,7 +163,7 @@ static void testBinaryToStringA(void)
CRYPT_STRING_BASE64X509CRLHEADER, tests[i].base64, X509_HEADER,
X509_TRAILER);
}
for (i = 0; i < sizeof(testsNoCR) / sizeof(testsNoCR[0]); i++)
for (i = 0; i < ARRAY_SIZE(testsNoCR); i++)
{
DWORD strLen = 0;
LPSTR str = NULL;
......@@ -380,7 +380,7 @@ static void testStringToBinaryA(void)
ok(!ret && GetLastError() == ERROR_INVALID_DATA,
"Expected ERROR_INVALID_DATA, got ret=%d le=%u\n", ret, GetLastError());
/* Bad strings */
for (i = 0; i < sizeof(badStrings) / sizeof(badStrings[0]); i++)
for (i = 0; i < ARRAY_SIZE(badStrings); i++)
{
bufLen = 0;
ret = CryptStringToBinaryA(badStrings[i].str, 0, badStrings[i].format,
......@@ -447,7 +447,7 @@ static void testStringToBinaryA(void)
ret, bufLen, buf[0]);
/* Good strings */
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
for (i = 0; i < ARRAY_SIZE(tests); i++)
{
bufLen = 0;
/* Bogus length--oddly enough, that succeeds, even though it's not
......@@ -504,7 +504,7 @@ static void testStringToBinaryA(void)
*/
}
/* And again, with no CR--decoding handles this automatically */
for (i = 0; i < sizeof(testsNoCR) / sizeof(testsNoCR[0]); i++)
for (i = 0; i < ARRAY_SIZE(testsNoCR); i++)
{
bufLen = 0;
/* Bogus length--oddly enough, that succeeds, even though it's not
......
......@@ -3177,7 +3177,7 @@ static void testCompareIntegerBlob(void)
DWORD i;
BOOL ret;
for (i = 0; i < sizeof(intBlobs) / sizeof(intBlobs[0]); i++)
for (i = 0; i < ARRAY_SIZE(intBlobs); i++)
{
ret = CertCompareIntegerBlob(&intBlobs[i].blob1, &intBlobs[i].blob2);
ok(ret == intBlobs[i].areEqual,
......
......@@ -36,7 +36,7 @@ static void test_findAttribute(void)
BYTE blobbin[] = {0x02,0x01,0x01};
static CHAR oid[] = "1.2.3";
CRYPT_ATTR_BLOB blobs[] = { { sizeof blobbin, blobbin }, };
CRYPT_ATTRIBUTE attr = { oid, sizeof(blobs) / sizeof(blobs[0]), blobs };
CRYPT_ATTRIBUTE attr = { oid, ARRAY_SIZE(blobs), blobs };
/* returns NULL, last error not set */
SetLastError(0xdeadbeef);
......@@ -128,10 +128,8 @@ static void test_findRDNAttr(void)
CERT_RDN_ATTR attrs[] = {
{ oid, CERT_RDN_IA5_STRING, { sizeof bin, bin } },
};
CERT_RDN rdns[] = {
{ sizeof(attrs) / sizeof(attrs[0]), attrs },
};
CERT_NAME_INFO nameInfo = { sizeof(rdns) / sizeof(rdns[0]), rdns };
CERT_RDN rdns[] = { { ARRAY_SIZE(attrs), attrs } };
CERT_NAME_INFO nameInfo = { ARRAY_SIZE(rdns), rdns };
if (0)
{
......
......@@ -575,7 +575,7 @@ static CRYPT_DATA_BLOB b1[] = {
{ sizeof(u2), u2 },
{ sizeof(u2), u2 },
};
static const struct update_accum a1 = { sizeof(b1) / sizeof(b1[0]), b1 };
static const struct update_accum a1 = { ARRAY_SIZE(b1), b1 };
/* The updates of a definite-length encoded message */
static BYTE u3[] = { 0x30,0x13,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,
0x07,0x01,0xa0,0x06,0x04,0x04 };
......@@ -583,7 +583,7 @@ static CRYPT_DATA_BLOB b2[] = {
{ sizeof(u3), u3 },
{ sizeof(u2), u2 },
};
static const struct update_accum a2 = { sizeof(b2) / sizeof(b2[0]), b2 };
static const struct update_accum a2 = { ARRAY_SIZE(b2), b2 };
/* The updates of an indefinite-length encoded message */
static BYTE u4[] = { 0x30,0x80,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,
0x07,0x01,0xa0,0x80,0x24,0x80 };
......@@ -597,7 +597,7 @@ static CRYPT_DATA_BLOB b3[] = {
{ sizeof(u2), u2 },
{ sizeof(u6), u6 },
};
static const struct update_accum a3 = { sizeof(b3) / sizeof(b3[0]), b3 };
static const struct update_accum a3 = { ARRAY_SIZE(b3), b3 };
static void check_updates(LPCSTR header, const struct update_accum *expected,
const struct update_accum *got)
......
......@@ -106,7 +106,7 @@ static void testOIDToAlgID(void)
alg = CertOIDToAlgId("1.2.3");
ok(!alg, "Expected failure, got %d\n", alg);
for (i = 0; i < sizeof(oidToAlgID) / sizeof(oidToAlgID[0]); i++)
for (i = 0; i < ARRAY_SIZE(oidToAlgID); i++)
{
alg = CertOIDToAlgId(oidToAlgID[i].oid);
ok(alg == oidToAlgID[i].algID || (oidToAlgID[i].altAlgID && alg == oidToAlgID[i].altAlgID),
......@@ -124,7 +124,7 @@ static void testAlgIDToOID(void)
oid = CertAlgIdToOID(ALG_CLASS_SIGNATURE | ALG_TYPE_ANY | 80);
ok(!oid && GetLastError() == 0xdeadbeef,
"Didn't expect last error (%08x) to be set\n", GetLastError());
for (i = 0; i < sizeof(algIDToOID) / sizeof(algIDToOID[0]); i++)
for (i = 0; i < ARRAY_SIZE(algIDToOID); i++)
{
oid = CertAlgIdToOID(algIDToOID[i].algID);
/* Allow failure, not every version of Windows supports every algo */
......@@ -424,7 +424,7 @@ static void test_registerDefaultOIDFunction(void)
DWORD type, size;
LPSTR ptr;
size = sizeof(dllBuf) / sizeof(dllBuf[0]);
size = ARRAY_SIZE(dllBuf);
rc = RegQueryValueExA(key, dllA, NULL, &type, (LPBYTE)dllBuf, &size);
ok(rc == 0,
"Expected Dll value to exist, RegQueryValueExA failed: %d\n", rc);
......
......@@ -187,9 +187,8 @@ static void test_SIPRetrieveSubjectGUID(void)
ok (ret > 0, "expected GEVA(windir) to succeed, last error %d\n", GetLastError());
strcat(regeditPath, "\\");
strcat(regeditPath, regeditExe);
MultiByteToWideChar( CP_ACP, 0, regeditPath,
strlen(regeditPath)+1, regeditPathW,
sizeof(regeditPathW)/sizeof(regeditPathW[0]) );
MultiByteToWideChar(CP_ACP, 0, regeditPath, strlen(regeditPath)+1, regeditPathW,
ARRAY_SIZE(regeditPathW));
SetLastError(0xdeadbeef);
memset(&subject, 1, sizeof(GUID));
......@@ -221,9 +220,7 @@ static void test_SIPRetrieveSubjectGUID(void)
/* Now with an empty file */
GetTempPathA(sizeof(path), path);
GetTempFileNameA(path, "sip", 0 , tempfile);
MultiByteToWideChar( CP_ACP, 0, tempfile,
strlen(tempfile)+1, tempfileW,
sizeof(tempfileW)/sizeof(tempfileW[0]) );
MultiByteToWideChar(CP_ACP, 0, tempfile, strlen(tempfile)+1, tempfileW, ARRAY_SIZE(tempfileW));
SetLastError(0xdeadbeef);
memset(&subject, 1, sizeof(GUID));
......
......@@ -385,7 +385,7 @@ static void testRegStoreSavedCerts(void)
BOOL ret;
DWORD res,i;
for (i = 0; i < sizeof(reg_store_saved_certs) / sizeof(reg_store_saved_certs[0]); i++)
for (i = 0; i < ARRAY_SIZE(reg_store_saved_certs); i++)
{
DWORD err;
......@@ -2081,7 +2081,7 @@ static void testCertRegisterSystemStore(void)
const CERT_CONTEXT *cert, *cert2;
unsigned int i;
for (i = 0; i < sizeof(reg_system_store_test_data) / sizeof(reg_system_store_test_data[0]); i++) {
for (i = 0; i < ARRAY_SIZE(reg_system_store_test_data); i++) {
cur_flag = reg_system_store_test_data[i].cert_store;
ret = CertRegisterSystemStore(WineTestW, cur_flag, NULL, NULL);
if (!ret)
......@@ -2469,7 +2469,7 @@ static void delete_test_key(void)
RegQueryInfoKeyW(test_key, NULL, NULL, NULL, &num_subkeys, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
for (idx = num_subkeys; idx-- > 0;)
{
subkey_name_len = sizeof(subkey_name)/sizeof(WCHAR);
subkey_name_len = ARRAY_SIZE(subkey_name);
RegEnumKeyExW(test_key, idx, subkey_name, &subkey_name_len, NULL, NULL, NULL, NULL);
RegDeleteKeyW(test_key, subkey_name);
}
......
......@@ -250,7 +250,7 @@ static void test_CertRDNValueToStrA(void)
ok(ret == 1 && GetLastError() == 0xdeadbeef, "Expected empty string\n");
ok(!buffer[0], "Expected empty string\n");
for (i = 0; i < sizeof(attrs) / sizeof(attrs[0]); i++)
for (i = 0; i < ARRAY_SIZE(attrs); i++)
{
ret = pCertRDNValueToStrA(attrs[i].dwValueType, &attrs[i].Value,
buffer, sizeof(buffer));
......@@ -341,15 +341,13 @@ static void test_CertRDNValueToStrW(void)
SetLastError(0xdeadbeef);
ret = pCertRDNValueToStrW(0, &blob, NULL, 0);
ok(ret == 1 && GetLastError() == 0xdeadbeef, "Expected empty string\n");
ret = pCertRDNValueToStrW(0, &blob, buffer,
sizeof(buffer) / sizeof(buffer[0]));
ret = pCertRDNValueToStrW(0, &blob, buffer, ARRAY_SIZE(buffer));
ok(ret == 1 && GetLastError() == 0xdeadbeef, "Expected empty string\n");
ok(!buffer[0], "Expected empty string\n");
for (i = 0; i < sizeof(attrs) / sizeof(attrs[0]); i++)
for (i = 0; i < ARRAY_SIZE(attrs); i++)
{
ret = pCertRDNValueToStrW(attrs[i].dwValueType, &attrs[i].Value,
buffer, sizeof(buffer) / sizeof(buffer[0]));
ret = pCertRDNValueToStrW(attrs[i].dwValueType, &attrs[i].Value, buffer, ARRAY_SIZE(buffer));
todo_wine_if (attrs[i].todo)
{
ok(ret == lstrlenW(attrs[i].str) + 1,
......@@ -550,8 +548,7 @@ static void test_NameToStrConversionW(PCERT_NAME_BLOB pName, DWORD dwStrType,
todo_wine_if (todo)
ok(i == lstrlenW(expected) + 1, "Expected %d chars, got %d\n",
lstrlenW(expected) + 1, i);
i = pCertNameToStrW(X509_ASN_ENCODING,pName, dwStrType, buffer,
sizeof(buffer) / sizeof(buffer[0]));
i = pCertNameToStrW(X509_ASN_ENCODING,pName, dwStrType, buffer, ARRAY_SIZE(buffer));
todo_wine_if (todo)
ok(i == lstrlenW(expected) + 1, "Expected %d chars, got %d\n",
lstrlenW(expected) + 1, i);
......@@ -795,7 +792,7 @@ static void test_CertStrToNameA(void)
&size, NULL);
ok(!ret && GetLastError() == ERROR_MORE_DATA,
"Expected ERROR_MORE_DATA, got %08x\n", GetLastError());
for (i = 0; i < sizeof(namesA) / sizeof(namesA[0]); i++)
for (i = 0; i < ARRAY_SIZE(namesA); i++)
{
size = sizeof(buf);
ret = pCertStrToNameA(X509_ASN_ENCODING, namesA[i].x500, 0, NULL, buf,
......@@ -889,7 +886,7 @@ static void test_CertStrToNameW(void)
ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
"Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
ok(errorPtr && *errorPtr == '1', "Expected first error character was 1\n");
for (i = 0; i < sizeof(namesW) / sizeof(namesW[0]); i++)
for (i = 0; i < ARRAY_SIZE(namesW); i++)
{
size = sizeof(buf);
ret = pCertStrToNameW(X509_ASN_ENCODING, namesW[i].x500, 0, NULL, buf,
......
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