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_int |
| ) |
|
Definition at line 40 of file test_conversions.c.
References ast_str_to_int(), AST_TEST_NOT_RUN, AST_TEST_PASS, CATEGORY, sip_to_pjsip::info(), NULL, str, TEST_EXECUTE, and TEST_INIT.
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";
56 info->name = __func__;
58 info->summary =
"convert a string to a signed integer";
77 ast_test_validate(
test, snprintf(str,
sizeof(str),
"%d", INT_MAX) > 0);
79 ast_test_validate(
test, val == INT_MAX);
81 ast_test_validate(
test, snprintf(str,
sizeof(str),
"%d", INT_MIN) > 0);
83 ast_test_validate(
test, val == INT_MIN);
int ast_str_to_int(const char *str, int *res)
Convert the given string to a signed integer.
◆ AST_TEST_DEFINE() [2/6]
AST_TEST_DEFINE |
( |
str_to_uint |
| ) |
|
Definition at line 88 of file test_conversions.c.
References ast_str_to_uint(), AST_TEST_NOT_RUN, AST_TEST_PASS, CATEGORY, sip_to_pjsip::info(), NULL, str, TEST_EXECUTE, and TEST_INIT.
90 const char *invalid =
"abc";
91 const char *invalid_partial =
"7abc";
92 const char *negative =
"-7";
93 const char *negative_spaces =
" -7";
94 const char *out_of_range =
"9999999999";
95 const char *spaces =
" ";
96 const char *valid =
"7";
97 const char *valid_spaces =
" 7";
103 info->name = __func__;
105 info->summary =
"convert a string to an unsigned integer";
123 ast_test_validate(
test, snprintf(str,
sizeof(str),
"%u", UINT_MAX) > 0);
125 ast_test_validate(
test, val == UINT_MAX);
int ast_str_to_uint(const char *str, unsigned int *res)
Convert the given string to an unsigned integer.
◆ AST_TEST_DEFINE() [3/6]
AST_TEST_DEFINE |
( |
str_to_long |
| ) |
|
Definition at line 130 of file test_conversions.c.
References ast_str_to_long(), AST_TEST_NOT_RUN, AST_TEST_PASS, CATEGORY, sip_to_pjsip::info(), NULL, str, TEST_EXECUTE, and TEST_INIT.
132 const char *invalid =
"abc";
133 const char *invalid_partial =
"7abc";
134 const char *negative =
"-7";
135 const char *negative_spaces =
" -7";
136 const char *negative_out_of_range =
"-99999999999999999999";
137 const char *out_of_range =
"99999999999999999999";
138 const char *spaces =
" ";
139 const char *valid =
"7";
140 const char *valid_spaces =
" 7";
146 info->name = __func__;
148 info->summary =
"convert a string to a signed long";
167 ast_test_validate(
test, snprintf(str,
sizeof(str),
"%ld", LONG_MAX) > 0);
169 ast_test_validate(
test, val == LONG_MAX);
171 ast_test_validate(
test, snprintf(str,
sizeof(str),
"%ld", LONG_MIN) > 0);
173 ast_test_validate(
test, val == LONG_MIN);
int ast_str_to_long(const char *str, long *res)
Convert the given string to a signed long.
◆ AST_TEST_DEFINE() [4/6]
AST_TEST_DEFINE |
( |
str_to_ulong |
| ) |
|
Definition at line 178 of file test_conversions.c.
References ast_str_to_ulong(), AST_TEST_NOT_RUN, AST_TEST_PASS, CATEGORY, sip_to_pjsip::info(), NULL, str, TEST_EXECUTE, and TEST_INIT.
180 const char *invalid =
"abc";
181 const char *invalid_partial =
"7abc";
182 const char *negative =
"-7";
183 const char *negative_spaces =
" -7";
184 const char *out_of_range =
"99999999999999999999";
185 const char *spaces =
" ";
186 const char *valid =
"7";
187 const char *valid_spaces =
" 7";
193 info->name = __func__;
195 info->summary =
"convert a string to an unsigned long";
213 ast_test_validate(
test, snprintf(str,
sizeof(str),
"%lu", ULONG_MAX) > 0);
215 ast_test_validate(
test, val == ULONG_MAX);
int ast_str_to_ulong(const char *str, unsigned long *res)
Convert the given string to an unsigned long.
◆ AST_TEST_DEFINE() [5/6]
AST_TEST_DEFINE |
( |
str_to_imax |
| ) |
|
Definition at line 220 of file test_conversions.c.
References ast_str_to_imax(), AST_TEST_NOT_RUN, AST_TEST_PASS, CATEGORY, sip_to_pjsip::info(), NULL, str, TEST_EXECUTE, and TEST_INIT.
222 const char *invalid =
"abc";
223 const char *invalid_partial =
"7abc";
224 const char *negative =
"-7";
225 const char *negative_spaces =
" -7";
226 const char *negative_out_of_range =
"-99999999999999999999999999999999999999999999999999";
227 const char *out_of_range =
"99999999999999999999999999999999999999999999999999";
228 const char *spaces =
" ";
229 const char *valid =
"7";
230 const char *valid_spaces =
" 7";
236 info->name = __func__;
238 info->summary =
"convert a string to a signed max size integer";
257 ast_test_validate(
test, snprintf(str,
sizeof(str),
"%jd", INTMAX_MAX) > 0);
259 ast_test_validate(
test, val == INTMAX_MAX);
261 ast_test_validate(
test, snprintf(str,
sizeof(str),
"%jd", INTMAX_MIN) > 0);
263 ast_test_validate(
test, val == INTMAX_MIN);
int ast_str_to_imax(const char *str, intmax_t *res)
Convert the given string to a signed max size integer.
◆ AST_TEST_DEFINE() [6/6]
AST_TEST_DEFINE |
( |
str_to_umax |
| ) |
|
Definition at line 269 of file test_conversions.c.
References ast_str_to_umax(), AST_TEST_NOT_RUN, AST_TEST_PASS, CATEGORY, sip_to_pjsip::info(), NULL, str, TEST_EXECUTE, and TEST_INIT.
271 const char *invalid =
"abc";
272 const char *invalid_partial =
"7abc";
273 const char *negative =
"-7";
274 const char *negative_spaces =
" -7";
275 const char *out_of_range =
"99999999999999999999999999999999999999999999999999";
276 const char *spaces =
" ";
277 const char *valid =
"7";
278 const char *valid_spaces =
" 7";
284 info->name = __func__;
286 info->summary =
"convert a string to an unsigned max size integer";
304 ast_test_validate(
test, snprintf(str,
sizeof(str),
"%ju", UINTMAX_MAX) > 0);
306 ast_test_validate(
test, val == UINTMAX_MAX);
int ast_str_to_umax(const char *str, uintmax_t *res)
Convert the given string to an unsigned max size integer.
◆ 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