diff --git a/tests/api.c b/tests/api.c index 2700c7a3a..725f0c708 100644 --- a/tests/api.c +++ b/tests/api.c @@ -14844,9 +14844,13 @@ static void test_wc_PKCS7_EncodeEncryptedData (void) /*----------------------------------------------------------------------------* | hash.h Tests *----------------------------------------------------------------------------*/ -static void test_wc_HashInit(void) +static int test_wc_HashInit(void) { - /*enum for holding supported algorithms, #ifndef's restrict if disabled*/ + int ret = 0, i; /* 0 indicates tests passed, 1 indicates failure */ + + wc_HashAlg hash; + + /* enum for holding supported algorithms, #ifndef's restrict if disabled */ enum wc_HashType enumArray[] = { #ifndef NO_MD5 WC_HASH_TYPE_MD5, @@ -14866,30 +14870,33 @@ static void test_wc_HashInit(void) #ifndef WOLFSSL_SHA512 WC_HASH_TYPE_SHA512, #endif - }; - int ret = 0; /*0 indicates tests passed, 1 indicates failure*/ - int enumlen = (sizeof(enumArray))/4;/*dynamically finds the length*/ + }; + /* dynamically finds the length */ + int enumlen = (sizeof(enumArray)/sizeof(enum wc_HashType)); - /*For loop to test various arguments...*/ - for(int i =0; i < enumlen; i++){ - wc_HashAlg hash; - if(wc_HashInit(&hash, enumArray[i])==BAD_FUNC_ARG){/*checking for bad args*/ - ret = 1; - } - if(wc_HashInit(NULL, enumArray[i])!=BAD_FUNC_ARG){/*checking for null ptr*/ - ret = 1; - } + /* For loop to test various arguments... */ + for(i = 0; i < enumlen; i++) { + /* check for bad args */ + if(wc_HashInit(&hash, enumArray[i]) == BAD_FUNC_ARG) { + ret = 1; + break; + } + /* check for null ptr */ + if(wc_HashInit(NULL, enumArray[i]) != BAD_FUNC_ARG) { + ret = 1; + break; + } }/* end of for loop */ printf(testingFmt, "wc_HashInit()"); - if(ret==0){/* all tests have passed */ + if(ret==0) { /* all tests have passed */ printf(resultFmt, passed); } - if(ret==1){/* a test has failed */ + if(ret==1) { /* a test has failed */ printf(resultFmt, failed); } - + return ret; }/* end of test_wc_HashInit */ @@ -18919,6 +18926,8 @@ void ApiTest(void) AssertFalse(test_wc_Sha384HmacUpdate()); AssertFalse(test_wc_Sha384HmacFinal()); + AssertIntEQ(test_wc_HashInit(), 0); + AssertIntEQ(test_wc_InitCmac(), 0); AssertIntEQ(test_wc_CmacUpdate(), 0); AssertIntEQ(test_wc_CmacFinal(), 0); @@ -19040,8 +19049,7 @@ void ApiTest(void) test_wc_PKCS7_VerifySignedData(); test_wc_PKCS7_EncodeDecodeEnvelopedData(); test_wc_PKCS7_EncodeEncryptedData(); - - test_wc_HashInit(); + printf(" End API Tests\n");