Debian Codegraph @

ext/safestringlib/unittests/test_strtouppercase_s.c

raw
1 /*------------------------------------------------------------------
2 * test_strtouppercase_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_strtouppercase_s()
15 {
16 errno_t rc;
17 rsize_t len;
18 char str[LEN];
19
20 /*--------------------------------------------------*/
21
22 len = 5;
23 //printf("debug - 01\n");
24 rc = strtouppercase_s(NULL, len);
25 if (rc != ESNULLP) {
26 printf("%s %u Error rc=%u \n",
27 __FUNCTION__, __LINE__, rc );
28 }
29
30 /*--------------------------------------------------*/
31
32 len = 0;
33 //printf("debug - 02\n");
34 rc = strtouppercase_s("test", len);
35 if (rc != ESZEROL) {
36 printf("%s %u Error rc=%u \n",
37 __FUNCTION__, __LINE__, rc );
38 }
39
40 /*--------------------------------------------------*/
41
42 /* empty string */
43 len = 5;
44 //printf("debug - 03\n");
45 rc = strtouppercase_s("", len);
46 if (rc != EOK) {
47 printf("%s %u Error rc=%u \n",
48 __FUNCTION__, __LINE__, rc );
49 }
50
51 /*--------------------------------------------------*/
52
53 /* FIXME: known bug: this test causes a bus error if the string max size is
54 not restricted via RSIZE_MAX_STR */
55 len = 99999;
56 //printf("debug - 04\n");
57 rc = strtouppercase_s("test", len);
58 if (rc != ESLEMAX) {
59 printf("%s %u Error rc=%u \n",
60 __FUNCTION__, __LINE__, rc );
61 }
62
63 /*--------------------------------------------------*/
64
65 strcpy (str, "n");
66 len = strlen(str);
67
68 //printf("debug - 05\n");
69 rc = strtouppercase_s(str, len);
70 if (rc != EOK) {
71 printf("%s %u Error rc=%u \n",
72 __FUNCTION__, __LINE__, rc );
73 }
74 //printf("debug - 06\n");
75
76 if (strcmp(str, "N") ) {
77 printf("%s %u Error -%s- \n",
78 __FUNCTION__, __LINE__, str);
79 }
80
81 /*--------------------------------------------------*/
82
83 strcpy (str, "N");
84 len = strlen(str);
85
86 //printf("debug - 07\n");
87 rc = strtouppercase_s(str, len);
88 if (rc != EOK) {
89 printf("%s %u Error rc=%u \n",
90 __FUNCTION__, __LINE__, rc );
91 }
92
93 //printf("debug - 08\n");
94 if (strcmp(str, "N") ) {
95 printf("%s %u Error -%s- \n",
96 __FUNCTION__, __LINE__, str);
97 }
98
99 /*--------------------------------------------------*/
100
101 strcpy (str, "nowisthetime");
102 len = strlen(str);
103
104 //printf("debug - 09\n");
105 rc = strtouppercase_s(str, len);
106 if (rc != EOK) {
107 printf("%s %u Error rc=%u \n",
108 __FUNCTION__, __LINE__, rc );
109 }
110
111 //printf("debug - 10\n");
112 if (strcmp(str, "NOWISTHETIME") ) {
113 printf("%s %u Error -%s- \n",
114 __FUNCTION__, __LINE__, str);
115 }
116
117 /*--------------------------------------------------*/
118
119 strcpy (str, "qqeRo");
120 len = strlen(str);
121
122 //printf("debug - 11\n");
123 rc = strtouppercase_s(str, len);
124 if (rc != EOK) {
125 printf("%s %u Error rc=%u \n",
126 __FUNCTION__, __LINE__, rc );
127 }
128
129 //printf("debug - 12\n");
130 if (strcmp(str, "QQERO") ) {
131 printf("%s %u Error -%s- \n",
132 __FUNCTION__, __LINE__, str);
133 }
134
135 /*--------------------------------------------------*/
136
137 strcpy (str, "1234");
138 len = strlen(str);
139
140 //printf("debug - 13\n");
141 rc = strtouppercase_s(str, 22);
142 if (rc != EOK) {
143 printf("%s %u Error rc=%u \n",
144 __FUNCTION__, __LINE__, rc );
145 }
146
147 /*--------------------------------------------------*/
148
149 return (0);
150 }