mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 19:24:42 +02:00
First unit test
This commit is contained in:
41
tests/api.c
41
tests/api.c
@@ -14730,6 +14730,45 @@ static void test_wc_PKCS7_EncodeEncryptedData (void)
|
||||
#endif
|
||||
} /* END test_wc_PKCS7_EncodeEncryptedData() */
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
| hash.h Tests
|
||||
*----------------------------------------------------------------------------*/
|
||||
static void test_wc_HashInit(void)
|
||||
{
|
||||
/*enum for holding supported algorithms, #ifndef's restrict if disabled*/
|
||||
enum wc_HashType enumArray[] = {
|
||||
#ifndef NO_MD5
|
||||
WC_HASH_TYPE_MD5,
|
||||
#endif
|
||||
#ifndef NO_SHA
|
||||
WC_HASH_TYPE_SHA,
|
||||
#endif
|
||||
#ifndef NO_SHA224
|
||||
WC_HASH_TYPE_SHA224,
|
||||
#endif
|
||||
#ifndef NO_SHA256
|
||||
WC_HASH_TYPE_SHA256,
|
||||
#endif
|
||||
#ifndef NO_SHA384
|
||||
WC_HASH_TYPE_SHA384,
|
||||
#endif
|
||||
#ifndef NO_SHA512
|
||||
WC_HASH_TYPE_SHA512,
|
||||
#endif
|
||||
};
|
||||
int enumlen = (sizeof(enumArray))/4;/*dynamically finds the length*/
|
||||
printf("the len of enum is: %d\n", enumlen);
|
||||
/*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*/
|
||||
printf("Testing with argument itm# %d with a goodPtr-BAD_FUNC_ARG\n", i);
|
||||
}
|
||||
if(wc_HashInit(NULL, enumArray[i])==BAD_FUNC_ARG){/*checking for null ptr*/
|
||||
printf("Testing with null pointer itm# %d returned BAD_FUNC_ARG\n", i);
|
||||
}
|
||||
}/* end of for loop */
|
||||
}/* end of test_wc_HashInit */
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
@@ -18876,6 +18915,8 @@ void ApiTest(void)
|
||||
test_wc_PKCS7_EncodeDecodeEnvelopedData();
|
||||
test_wc_PKCS7_EncodeEncryptedData();
|
||||
|
||||
test_wc_HashInit();
|
||||
|
||||
printf(" End API Tests\n");
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user