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";
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);
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);
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);
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);
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);
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);
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk main include file. File version handling, generic pbx functions.
int ast_str_to_umax(const char *str, uintmax_t *res)
Convert the given string to an unsigned max size integer.
static int unload_module(void)
#define AST_TEST_REGISTER(cb)
int ast_str_to_imax(const char *str, intmax_t *res)
Convert the given string to a signed max size integer.
Conversion utility functions.
int ast_str_to_int(const char *str, int *res)
Convert the given string to a signed integer.
#define AST_TEST_UNREGISTER(cb)
int ast_str_to_ulong(const char *str, unsigned long *res)
Convert the given string to an unsigned long.
int ast_str_to_uint(const char *str, unsigned int *res)
Convert the given string to an unsigned integer.
static int load_module(void)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
int ast_str_to_long(const char *str, long *res)
Convert the given string to a signed long.
AST_TEST_DEFINE(str_to_int)