Debian Codegraph @

ext/safestringlib/unittests/test_strispassword_s.c

raw
1 /*------------------------------------------------------------------
2 * test_strispassword_s
3 *
4 *
5 *------------------------------------------------------------------
6 */
7
8 #include "test_private.h"
9 #include "safe_str_lib.h"
10
11 #define LEN 64
12
13
14 int test_strispassword_s()
15 {
16 bool rc;
17 uint32_t len;
18 char str[LEN];
19
20 /*--------------------------------------------------*/
21
22 rc = strispassword_s(NULL, LEN);
23 if (rc != false) {
24 printf("%s %u Error rc=%u \n",
25 __FUNCTION__, __LINE__, rc );
26 }
27
28 /*--------------------------------------------------*/
29
30 rc = strispassword_s("", LEN);
31 if (rc != false) {
32 printf("%s %u Error rc=%u \n",
33 __FUNCTION__, __LINE__, rc );
34 }
35
36 /*--------------------------------------------------*/
37
38 rc = strispassword_s("Test4You&", 0);
39 if (rc != false) {
40 printf("%s %u Error rc=%u \n",
41 __FUNCTION__, __LINE__, rc );
42 }
43
44 /*--------------------------------------------------*/
45
46 rc = strispassword_s("Test4You&", 999);
47 if (rc != false) {
48 printf("%s %u Error rc=%u \n",
49 __FUNCTION__, __LINE__, rc );
50 }
51
52 /*--------------------------------------------------*/
53
54 rc = strispassword_s("", 9);
55 if (rc != false) {
56 printf("%s %u Error rc=%u \n",
57 __FUNCTION__, __LINE__, rc );
58 }
59
60 /*--------------------------------------------------*/
61
62 strcpy (str, "Test4You*123");
63 len = 8;
64
65 rc = strispassword_s(str, len);
66 if (rc != false) {
67 printf("%s %u Error rc=%u \n",
68 __FUNCTION__, __LINE__, rc );
69 }
70
71 /*--------------------------------------------------*/
72
73 strcpy (str, "Test4You*");
74 len = strlen(str);
75
76 rc = strispassword_s(str, len);
77 if (rc != true) {
78 printf("%s %u Error rc=%u \n",
79 __FUNCTION__, __LINE__, rc );
80 }
81
82 /*--------------------------------------------------*/
83
84 strcpy (str, "Test4You*Test4You*Test4You*");
85 len = strlen(str);
86
87 rc = strispassword_s(str, len);
88 if (rc != true) {
89 printf("%s %u Error rc=%u \n",
90 __FUNCTION__, __LINE__, rc );
91 }
92
93 /*--------------------------------------------------*/
94
95 strcpy (str, "Eest!22/");
96 len = strlen(str);
97
98 rc = strispassword_s(str, len);
99 if (rc != false) {
100 printf("%s %u Error rc=%u \n",
101 __FUNCTION__, __LINE__, rc );
102 }
103
104 /*--------------------------------------------------*/
105
106 strcpy (str, "pa$$W0rD");
107 len = strlen(str);
108
109 rc = strispassword_s(str, len);
110 if (rc != true) {
111 printf("%s %u Error rc=%u \n",
112 __FUNCTION__, __LINE__, rc );
113 }
114
115 /*--------------------------------------------------*/
116
117 strcpy (str, "Test");
118 len = strlen(str);
119
120 rc = strispassword_s(str, len);
121 if (rc != false) {
122 printf("%s %u Error rc=%u \n",
123 __FUNCTION__, __LINE__, rc );
124 }
125
126 /*--------------------------------------------------*/
127
128 return (0);
129 }