/*------------------------------------------------------------------ * test_strcpy_s * * *------------------------------------------------------------------ */ #include "test_private.h" #include "safe_str_lib.h" #define MAX ( 128 ) #define LEN ( 128 ) static char str1[LEN]; static char str2[LEN]; int test_strcpy_s (void) { errno_t rc; #ifdef SAFE_LIB_STR_NULL_SLACK uint32_t i; #endif /*SAFE_LIB_STR_NULL_SLACK*/ int32_t ind; /*--------------------------------------------------*/ rc = strcpy_s(NULL, LEN, str2); if (rc != ESNULLP) { debug_printf("%s %u Error rc=%u \n", __FUNCTION__, __LINE__, rc ); } /*--------------------------------------------------*/ strcpy(str1, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); rc = strcpy_s(str1, 5, NULL); if (rc != ESNULLP) { debug_printf("%s %u Error rc=%u \n", __FUNCTION__, __LINE__, rc ); } #ifdef SAFE_LIB_STR_NULL_SLACK for (i=0; i<5; i++) { if (str1[i] != '\0') { debug_printf("%s %u Error rc=%u \n", __FUNCTION__, __LINE__, rc ); } } #else if (str1[0] != '\0') { debug_printf("%s %u Error rc=%u \n", __FUNCTION__, __LINE__, rc ); } #endif /*--------------------------------------------------*/ rc = strcpy_s(str1, 0, str2); if (rc != ESZEROL) { debug_printf("%s %u Error rc=%u \n", __FUNCTION__, __LINE__, rc ); } /*--------------------------------------------------*/ rc = strcpy_s(str1, (RSIZE_MAX_STR+1), str2); if (rc != ESLEMAX) { debug_printf("%s %u Error rc=%u \n", __FUNCTION__, __LINE__, rc ); } /*--------------------------------------------------*/ /*--------------------------------------------------*/ strcpy(str1, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); str2[0] = '\0'; rc = strcpy_s(str1, LEN/2, str2); if (rc != EOK) { debug_printf("%s %u Error rc=%u \n", __FUNCTION__, __LINE__, rc ); } #ifdef SAFE_LIB_STR_NULL_SLACK for (i=0; i