Debian Codegraph @

ext/safestringlib/unittests/test_strisascii_s.c

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