/*------------------------------------------------------------------ * test_strisalphanumeric_s.c * * *------------------------------------------------------------------ */ #include "test_private.h" #include "safe_str_lib.h" #define LEN ( 128 ) int test_strisalphanumeric_s() { bool rc; uint32_t len; char str[LEN]; /*--------------------------------------------------*/ len = 5; rc = strisalphanumeric_s(NULL, len); if (rc != false) { printf("%s %u Error rc=%u \n", __FUNCTION__, __LINE__, rc ); } /*--------------------------------------------------*/ len = 0; rc = strisalphanumeric_s("test", len); if (rc != false) { printf("%s %u Error rc=%u \n", __FUNCTION__, __LINE__, rc ); } /*--------------------------------------------------*/ /* exceeds max */ len = 99999; rc = strisalphanumeric_s("test", len); if (rc != false) { printf("%s %u Error rc=%u \n", __FUNCTION__, __LINE__, rc ); } /*--------------------------------------------------*/ /* empty string */ rc = strisalphanumeric_s("", LEN); if (rc != false) { printf("%s %u Error rc=%u \n", __FUNCTION__, __LINE__, rc ); } /*--------------------------------------------------*/ strcpy(str, "123456789"); len = 4; rc = strisalphanumeric_s(str, len); if (rc != true) { printf("%s %u Error rc=%u \n", __FUNCTION__, __LINE__, rc ); } /*--------------------------------------------------*/ strcpy(str, "N"); rc = strisalphanumeric_s(str, 1); if (rc != true) { printf("%s %u Error rc=%u \n", __FUNCTION__, __LINE__, rc ); } /*--------------------------------------------------*/ strcpy(str, "N"); len = strlen(str); rc = strisalphanumeric_s(str, len); if (rc != true) { printf("%s %u Error rc=%u \n", __FUNCTION__, __LINE__, rc ); } /*--------------------------------------------------*/ strcpy(str, "NowISTHETimE4us"); len = strlen(str); rc = strisalphanumeric_s(str, len); if (rc != true) { printf("%s %u Error rc=%u \n", __FUNCTION__, __LINE__, rc ); } /*--------------------------------------------------*/ strcpy(str, "qq21ego"); len = strlen(str); rc = strisalphanumeric_s(str, len); if (rc != true) { printf("%s %u Error rc=%u \n", __FUNCTION__, __LINE__, rc ); } /*--------------------------------------------------*/ strcpy(str, "1234"); str[2] = 132; /* special char */ len = strlen(str); /* special char embedded */ rc = strisalphanumeric_s(str, len); if (rc != false) { printf("%s %u Error rc=%u \n", __FUNCTION__, __LINE__, rc ); } /*--------------------------------------------------*/ strcpy(str, "!@#$%^&*(){}[]:;\"'?/.>,<"); len = strlen(str); rc = strisalphanumeric_s(str, len); if (rc != false) { printf("%s %u Error rc=%u \n", __FUNCTION__, __LINE__, rc ); } /*--------------------------------------------------*/ return (0); }