Debian Codegraph @

ext/safestringlib/unittests/test_strtolowercase_s.c

raw
1 /*------------------------------------------------------------------
2 * test_strtolowercase_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_strtolowercase_s()
15 {
16 errno_t rc;
17 rsize_t len;
18 char str[LEN];
19
20 /*--------------------------------------------------*/
21
22 len = 5;
23 rc = strtolowercase_s(NULL, len);
24 if (rc != ESNULLP) {
25 printf("%s %u Error rc=%u \n",
26 __FUNCTION__, __LINE__, rc );
27 }
28
29 /*--------------------------------------------------*/
30
31 len = 0;
32 rc = strtolowercase_s("test", len);
33 if (rc != ESZEROL) {
34 printf("%s %u Error rc=%u \n",
35 __FUNCTION__, __LINE__, rc );
36 }
37
38 /*--------------------------------------------------*/
39
40 len = 99999;
41 rc = strtolowercase_s("test", len);
42 if (rc != ESLEMAX) {
43 printf("%s %u Error rc=%u \n",
44 __FUNCTION__, __LINE__, rc );
45 }
46
47 /*--------------------------------------------------*/
48
49 strcpy(str, "N");
50 len = strlen(str);
51
52 rc = strtolowercase_s(str, len);
53 if (rc != EOK) {
54 printf("%s %u Error rc=%u \n",
55 __FUNCTION__, __LINE__, rc );
56 }
57
58 if (strcmp(str, "n") ) {
59 printf("%s %u Error -%s- \n",
60 __FUNCTION__, __LINE__, str);
61 }
62
63 /*--------------------------------------------------*/
64
65 strcpy(str, "n");
66 len = strlen(str);
67
68 rc = strtolowercase_s(str, len);
69 if (rc != EOK) {
70 printf("%s %u Error rc=%u \n",
71 __FUNCTION__, __LINE__, rc );
72 }
73
74 if (strcmp(str, "n") ) {
75 printf("%s %u Error -%s- \n",
76 __FUNCTION__, __LINE__, str);
77 }
78
79 /*--------------------------------------------------*/
80
81 strcpy(str, "NOWISTHETIM3");
82
83 rc = strtolowercase_s(str, 25);
84 if (rc != EOK) {
85 printf("%s %u Error rc=%u \n",
86 __FUNCTION__, __LINE__, rc );
87 }
88
89 if (strcmp(str, "nowisthetim3") ) {
90 printf("%s %u Error -%s- \n",
91 __FUNCTION__, __LINE__, str);
92 }
93
94 /*--------------------------------------------------*/
95
96 strcpy(str, "NOWISTHETIME");
97 len = strlen(str);
98
99 rc = strtolowercase_s(str, len);
100 if (rc != EOK) {
101 printf("%s %u Error rc=%u \n",
102 __FUNCTION__, __LINE__, rc );
103 }
104
105 if (strcmp(str, "nowisthetime") ) {
106 printf("%s %u Error -%s- \n",
107 __FUNCTION__, __LINE__, str);
108 }
109
110 /*--------------------------------------------------*/
111
112 strcpy(str, "qqeRo");
113 len = strlen(str);
114
115 rc = strtolowercase_s(str, len);
116 if (rc != EOK) {
117 printf("%s %u Error rc=%u \n",
118 __FUNCTION__, __LINE__, rc );
119 }
120
121 if (strcmp(str, "qqero") ) {
122 printf("%s %u Error -%s- \n",
123 __FUNCTION__, __LINE__, str);
124 }
125
126 /*--------------------------------------------------*/
127
128 strcpy(str, "1234");
129 len = strlen(str);
130
131 rc = strtolowercase_s(str, 4);
132 if (rc != EOK) {
133 printf("%s %u Error rc=%u \n",
134 __FUNCTION__, __LINE__, rc );
135 }
136
137 /*--------------------------------------------------*/
138
139
140 return (0);
141 }