1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
/*------------------------------------------------------------------
* test_strispassword_s
* File 'extstr/strispassword_s.c'
* Lines executed:97.44% of 39
*
*------------------------------------------------------------------
*/
#include "test_private.h"
#include "safe_str_lib.h"
#define LEN 64
int main(void) {
bool rc;
uint32_t len;
char str[LEN];
int errs = 0;
/*--------------------------------------------------*/
#ifndef HAVE_CT_BOS_OVR
EXPECT_BOS("empty dest")
rc = strispassword_s(NULL, LEN);
ERR(false)
EXPECT_BOS("empty dest or dmax")
rc = strispassword_s("Test4You&", 0);
ERR(false)
strcpy(str, "Test4You&");
EXPECT_BOS("dest overflow")
rc = strispassword_s(str, RSIZE_MAX_STR + 1);
ERR(false)
EXPECT_BOS("dest overflow")
rc = strispassword_s("Test4You&", SAFE_STR_PASSWORD_MAX_LENGTH + 1);
ERR(false)
EXPECT_BOS("dest overflow")
rc = strispassword_s("", 9);
ERR(false)
EXPECT_BOS("dest overflow")
rc = strispassword_s("", LEN);
ERR(false)
#endif
/*--------------------------------------------------*/
//EXPECT_BOS("dest is too short")
rc = strispassword_s("a", 1);
ERR(false)
strcpy(str, "Test4You*123");
len = 8;
rc = strispassword_s(str, len);
ERR(false)
/*--------------------------------------------------*/
strcpy(str, "Test4You*");
len = strlen(str);
rc = strispassword_s(str, len);
ERR(true)
/*--------------------------------------------------*/
strcpy(str, "Test4You*Test4You*Test4You*");
len = strlen(str);
rc = strispassword_s(str, len);
ERR(true)
/*--------------------------------------------------*/
strcpy(str, "Eest!22/");
len = strlen(str);
rc = strispassword_s(str, len);
ERR(false)
/*--------------------------------------------------*/
strcpy(str, "pa$$W0rD");
len = strlen(str);
rc = strispassword_s(str, len);
ERR(true)
strcpy(str, "<a]$b}0X_D");
len = strlen(str);
rc = strispassword_s(str, len);
ERR(true)
/*--------------------------------------------------*/
strcpy(str, "pa$$W0rD f");
len = strlen(str);
rc = strispassword_s(str, len);
ERR(false)
strcpy(str, "Test");
len = strlen(str);
rc = strispassword_s(str, len);
ERR(false)
/*--------------------------------------------------*/
return (errs);
}
|