38#define CATEGORY "/main/conversions/"
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";
57 info->name = __func__;
59 info->summary =
"convert a string to a signed integer";
79 ast_test_validate(
test, snprintf(
str,
sizeof(
str),
"%d", INT_MAX) > 0);
81 ast_test_validate(
test,
val == INT_MAX);
83 ast_test_validate(
test, snprintf(
str,
sizeof(
str),
"%d", INT_MIN) > 0);
85 ast_test_validate(
test,
val == INT_MIN);
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";
106 info->name = __func__;
108 info->summary =
"convert a string to an unsigned integer";
127 ast_test_validate(
test, snprintf(
str,
sizeof(
str),
"%u", UINT_MAX) > 0);
129 ast_test_validate(
test,
val == UINT_MAX);
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";
151 info->name = __func__;
153 info->summary =
"convert a string to a signed long";
173 ast_test_validate(
test, snprintf(
str,
sizeof(
str),
"%ld", LONG_MAX) > 0);
175 ast_test_validate(
test,
val == LONG_MAX);
177 ast_test_validate(
test, snprintf(
str,
sizeof(
str),
"%ld", LONG_MIN) > 0);
179 ast_test_validate(
test,
val == LONG_MIN);
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";
200 info->name = __func__;
202 info->summary =
"convert a string to an unsigned long";
221 ast_test_validate(
test, snprintf(
str,
sizeof(
str),
"%lu", ULONG_MAX) > 0);
223 ast_test_validate(
test,
val == ULONG_MAX);
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";
245 info->name = __func__;
247 info->summary =
"convert a string to a signed max size integer";
267 ast_test_validate(
test, snprintf(
str,
sizeof(
str),
"%jd", INTMAX_MAX) > 0);
269 ast_test_validate(
test,
val == INTMAX_MAX);
271 ast_test_validate(
test, snprintf(
str,
sizeof(
str),
"%jd", INTMAX_MIN) > 0);
273 ast_test_validate(
test,
val == INTMAX_MIN);
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";
295 info->name = __func__;
297 info->summary =
"convert a string to an unsigned max size integer";
316 ast_test_validate(
test, snprintf(
str,
sizeof(
str),
"%ju", UINTMAX_MAX) > 0);
318 ast_test_validate(
test,
val == UINTMAX_MAX);
Asterisk main include file. File version handling, generic pbx functions.
Conversion utility functions.
int ast_str_to_long(const char *str, long *res)
Convert the given string to a signed long.
int ast_str_to_imax(const char *str, intmax_t *res)
Convert the given string to a signed max size integer.
int ast_str_to_umax(const char *str, uintmax_t *res)
Convert the given string to an unsigned max size integer.
int ast_str_to_int(const char *str, int *res)
Convert the given string to a signed integer.
int ast_str_to_uint(const char *str, unsigned int *res)
Convert the given string to an unsigned integer.
int ast_str_to_ulong(const char *str, unsigned long *res)
Convert the given string to an unsigned long.
Asterisk module definitions.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
#define AST_TEST_REGISTER(cb)
#define AST_TEST_UNREGISTER(cb)
AST_TEST_DEFINE(str_to_int)
static int load_module(void)
static int unload_module(void)