Conversions Unit Tests.
More...
Go to the source code of this file.
|
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Conversions test module" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, } |
|
static const struct ast_module_info * | ast_module_info = &__mod_info |
|
◆ CATEGORY
#define CATEGORY "/main/conversions/" |
◆ __reg_module()
static void __reg_module |
( |
void |
| ) |
|
|
static |
◆ __unreg_module()
static void __unreg_module |
( |
void |
| ) |
|
|
static |
◆ AST_MODULE_SELF_SYM()
◆ AST_TEST_DEFINE() [1/6]
AST_TEST_DEFINE |
( |
str_to_imax |
| ) |
|
Definition at line 228 of file test_conversions.c.
229{
230 const char *invalid = "abc";
231 const char *invalid_partial = "7abc";
232 const char *negative = "-7";
233 const char *negative_spaces = " -7";
234 const char *negative_out_of_range = "-99999999999999999999999999999999999999999999999999";
235 const char *out_of_range = "99999999999999999999999999999999999999999999999999";
236 const char *spaces = " ";
237 const char *valid = "7";
238 const char *valid_spaces = " 7";
239 const char *valid_decimal = "08";
242
243 switch (cmd) {
245 info->name = __func__;
247 info->summary =
"convert a string to a signed max size integer";
251 break;
252 }
253
266
267 ast_test_validate(
test, snprintf(
str,
sizeof(
str),
"%jd", INTMAX_MAX) > 0);
269 ast_test_validate(
test,
val == INTMAX_MAX);
270
271 ast_test_validate(
test, snprintf(
str,
sizeof(
str),
"%jd", INTMAX_MIN) > 0);
273 ast_test_validate(
test,
val == INTMAX_MIN);
274
276}
int ast_str_to_imax(const char *str, intmax_t *res)
Convert the given string to a signed max size integer.
References ast_str_to_imax(), AST_TEST_NOT_RUN, AST_TEST_PASS, CATEGORY, sip_to_pjsip::info(), NULL, str, TEST_EXECUTE, and TEST_INIT.
◆ AST_TEST_DEFINE() [2/6]
AST_TEST_DEFINE |
( |
str_to_int |
| ) |
|
Definition at line 40 of file test_conversions.c.
41{
42 const char *invalid = "abc";
43 const char *invalid_partial = "7abc";
44 const char *negative = "-7";
45 const char *negative_spaces = " -7";
46 const char *negative_out_of_range = "-9999999999";
47 const char *out_of_range = "9999999999";
48 const char *spaces = " ";
49 const char *valid = "7";
50 const char *valid_spaces = " 7";
51 const char *valid_decimal = "08";
54
55 switch (cmd) {
57 info->name = __func__;
59 info->summary =
"convert a string to a signed integer";
63 break;
64 }
65
78
79 ast_test_validate(
test, snprintf(
str,
sizeof(
str),
"%d", INT_MAX) > 0);
81 ast_test_validate(
test,
val == INT_MAX);
82
83 ast_test_validate(
test, snprintf(
str,
sizeof(
str),
"%d", INT_MIN) > 0);
85 ast_test_validate(
test,
val == INT_MIN);
86
88}
int ast_str_to_int(const char *str, int *res)
Convert the given string to a signed integer.
References ast_str_to_int(), AST_TEST_NOT_RUN, AST_TEST_PASS, CATEGORY, sip_to_pjsip::info(), NULL, str, TEST_EXECUTE, and TEST_INIT.
◆ AST_TEST_DEFINE() [3/6]
AST_TEST_DEFINE |
( |
str_to_long |
| ) |
|
Definition at line 134 of file test_conversions.c.
135{
136 const char *invalid = "abc";
137 const char *invalid_partial = "7abc";
138 const char *negative = "-7";
139 const char *negative_spaces = " -7";
140 const char *negative_out_of_range = "-99999999999999999999";
141 const char *out_of_range = "99999999999999999999";
142 const char *spaces = " ";
143 const char *valid = "7";
144 const char *valid_spaces = " 7";
145 const char *valid_decimal = "08";
148
149 switch (cmd) {
151 info->name = __func__;
153 info->summary =
"convert a string to a signed long";
157 break;
158 }
159
172
173 ast_test_validate(
test, snprintf(
str,
sizeof(
str),
"%ld", LONG_MAX) > 0);
175 ast_test_validate(
test,
val == LONG_MAX);
176
177 ast_test_validate(
test, snprintf(
str,
sizeof(
str),
"%ld", LONG_MIN) > 0);
179 ast_test_validate(
test,
val == LONG_MIN);
180
182}
int ast_str_to_long(const char *str, long *res)
Convert the given string to a signed long.
References ast_str_to_long(), AST_TEST_NOT_RUN, AST_TEST_PASS, CATEGORY, sip_to_pjsip::info(), NULL, str, TEST_EXECUTE, and TEST_INIT.
◆ AST_TEST_DEFINE() [4/6]
AST_TEST_DEFINE |
( |
str_to_uint |
| ) |
|
Definition at line 90 of file test_conversions.c.
91{
92 const char *invalid = "abc";
93 const char *invalid_partial = "7abc";
94 const char *negative = "-7";
95 const char *negative_spaces = " -7";
96 const char *out_of_range = "9999999999";
97 const char *spaces = " ";
98 const char *valid = "7";
99 const char *valid_spaces = " 7";
100 const char *valid_decimal = "08";
103
104 switch (cmd) {
106 info->name = __func__;
108 info->summary =
"convert a string to an unsigned integer";
112 break;
113 }
114
126
127 ast_test_validate(
test, snprintf(
str,
sizeof(
str),
"%u", UINT_MAX) > 0);
129 ast_test_validate(
test,
val == UINT_MAX);
130
132}
int ast_str_to_uint(const char *str, unsigned int *res)
Convert the given string to an unsigned integer.
References ast_str_to_uint(), AST_TEST_NOT_RUN, AST_TEST_PASS, CATEGORY, sip_to_pjsip::info(), NULL, str, TEST_EXECUTE, and TEST_INIT.
◆ AST_TEST_DEFINE() [5/6]
AST_TEST_DEFINE |
( |
str_to_ulong |
| ) |
|
Definition at line 184 of file test_conversions.c.
185{
186 const char *invalid = "abc";
187 const char *invalid_partial = "7abc";
188 const char *negative = "-7";
189 const char *negative_spaces = " -7";
190 const char *out_of_range = "99999999999999999999";
191 const char *spaces = " ";
192 const char *valid = "7";
193 const char *valid_spaces = " 7";
194 const char *valid_decimal = "08";
197
198 switch (cmd) {
200 info->name = __func__;
202 info->summary =
"convert a string to an unsigned long";
206 break;
207 }
208
220
221 ast_test_validate(
test, snprintf(
str,
sizeof(
str),
"%lu", ULONG_MAX) > 0);
223 ast_test_validate(
test,
val == ULONG_MAX);
224
226}
int ast_str_to_ulong(const char *str, unsigned long *res)
Convert the given string to an unsigned long.
References ast_str_to_ulong(), AST_TEST_NOT_RUN, AST_TEST_PASS, CATEGORY, sip_to_pjsip::info(), NULL, str, TEST_EXECUTE, and TEST_INIT.
◆ AST_TEST_DEFINE() [6/6]
AST_TEST_DEFINE |
( |
str_to_umax |
| ) |
|
Definition at line 279 of file test_conversions.c.
280{
281 const char *invalid = "abc";
282 const char *invalid_partial = "7abc";
283 const char *negative = "-7";
284 const char *negative_spaces = " -7";
285 const char *out_of_range = "99999999999999999999999999999999999999999999999999";
286 const char *spaces = " ";
287 const char *valid = "7";
288 const char *valid_spaces = " 7";
289 const char *valid_decimal = "08";
292
293 switch (cmd) {
295 info->name = __func__;
297 info->summary =
"convert a string to an unsigned max size integer";
301 break;
302 }
303
315
316 ast_test_validate(
test, snprintf(
str,
sizeof(
str),
"%ju", UINTMAX_MAX) > 0);
318 ast_test_validate(
test,
val == UINTMAX_MAX);
319
321}
int ast_str_to_umax(const char *str, uintmax_t *res)
Convert the given string to an unsigned max size integer.
References ast_str_to_umax(), AST_TEST_NOT_RUN, AST_TEST_PASS, CATEGORY, sip_to_pjsip::info(), NULL, str, TEST_EXECUTE, and TEST_INIT.
◆ load_module()
static int load_module |
( |
void |
| ) |
|
|
static |
◆ unload_module()
static int unload_module |
( |
void |
| ) |
|
|
static |
◆ __mod_info
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Conversions test module" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, } |
|
static |
◆ ast_module_info