50#define STRING_CMP(a, b) ({ \
51 ((void *)(a) == (void *)NULL || (void *)(b) == (void *)NULL) ? -1 : (strcmp((a), (b)) == 0); \
70 info->category =
"/main/vector/";
71 info->summary =
"Test vector basic ops";
72 info->description =
"Test vector basic ops";
79 ast_test_validate_cleanup(
test, sv1.max == 3, rc,
cleanup);
83 ast_test_validate_cleanup(
test, sv1.max == 3, rc,
cleanup);
85 ast_test_validate_cleanup(
test, sv1.max == 3, rc,
cleanup);
88 ast_test_validate_cleanup(
test, sv1.max >= 3, rc,
cleanup);
92 ast_test_validate_cleanup(
test, sv1.max == sv1.current, rc,
cleanup);
96 ast_test_validate_cleanup(
test, sv1.max == 8, rc,
cleanup);
105 ast_test_validate_cleanup(
test, sv1.current == 7, rc,
cleanup);
107 ast_test_validate_cleanup(
test, sv1.max == 8, rc,
cleanup);
116 ast_test_validate_cleanup(
test, sv1.current == 13, rc,
cleanup);
118 ast_test_validate_cleanup(
test, sv1.max == 26, rc,
cleanup);
122 ast_test_validate(
test, sv1.elems ==
NULL);
123 ast_test_validate(
test, sv1.current == 0);
124 ast_test_validate(
test, sv1.max == 0);
128 ast_test_validate_cleanup(
test, sv1.max == 0, rc,
cleanup);
134 ast_test_validate_cleanup(
test, sv1.max >= 3, rc,
cleanup);
143 ast_test_validate_cleanup(
test, sv1.current == 3, rc,
cleanup);
150 ast_test_validate_cleanup(
test, sv1.current == 11, rc,
cleanup);
159 ast_test_validate_cleanup(
test, sv1.current == 101, rc,
cleanup);
160 ast_test_validate_cleanup(
test, sv1.max >= 101, rc,
cleanup);
164 ast_test_validate_cleanup(
test, sv1.current == 100, rc,
cleanup);
171 ast_test_validate_cleanup(
test, sv1.current == 100, rc,
cleanup);
178 ast_test_validate_cleanup(
test, sv1.current == 99, rc,
cleanup);
183 ast_test_validate_cleanup(
test, sv1.current == 100, rc,
cleanup);
191 ast_test_validate_cleanup(
test, sv1.current == 99, rc,
cleanup);
224 ast_test_validate_cleanup(
test, sv1.max >= 5, rc,
cleanup);
250 info->name =
"basic_integer";
251 info->category =
"/main/vector/";
252 info->summary =
"Test integer vector basic ops";
253 info->description =
"Test integer vector basic ops";
260 ast_test_validate_cleanup(
test, sv1.max == 3, rc,
cleanup);
264 ast_test_validate_cleanup(
test, sv1.max == 3, rc,
cleanup);
266 ast_test_validate_cleanup(
test, sv1.max == 3, rc,
cleanup);
269 ast_test_validate_cleanup(
test, sv1.max == 3, rc,
cleanup);
275 ast_test_validate_cleanup(
test, sv1.max >= 4, rc,
cleanup);
305 ast_test_validate(
test, sv1.elems ==
NULL);
306 ast_test_validate(
test, sv1.current == 0);
307 ast_test_validate(
test, sv1.max == 0);
310 ast_test_validate_cleanup(
test, sv1.max == 0, rc,
cleanup);
316 ast_test_validate_cleanup(
test, sv1.max >= 3, rc,
cleanup);
388 return strcmp(arg, obj) == 0 ?
CMP_MATCH : 0;
407 char *DEF =
"default_value";
411 info->name =
"callbacks";
412 info->category =
"/main/vector/";
413 info->summary =
"Test vector callback ops";
414 info->description =
"Test vector callback ops";
475 info->name =
"locks";
476 info->category =
"/main/vector/";
477 info->summary =
"Test vector locking ops";
478 info->description =
"Test vector locking ops";
Asterisk main include file. File version handling, generic pbx functions.
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
String manipulation functions.
#define AST_TEST_REGISTER(cb)
#define AST_TEST_UNREGISTER(cb)
static void cleanup_int(int element)
AST_TEST_DEFINE(basic_ops)
static int cb_visits(void *obj, int v)
static void cleanup(char *element)
static int cb_match(void *obj, void *arg)
static int load_module(void)
static int unload_module(void)
typedef typeof(dummy_tv_var_for_types.tv_sec) ast_time_t
Vector container support.
#define AST_VECTOR_REMOVE_ORDERED(vec, idx)
Remove an element from a vector by index while maintaining order.
#define AST_VECTOR_REPLACE(vec, idx, elem)
Replace an element at a specific position in a vector, growing the vector if needed.
#define AST_VECTOR_RW_WRLOCK_TRY(vec)
Try to obtain write lock on vector failing immediately if unable.
#define AST_VECTOR_RESET(vec, cleanup)
Reset vector.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
#define AST_VECTOR_GET_INDEX(vec, value, cmp)
Get the 1st index from a vector that matches the given comparison.
#define AST_VECTOR_GET_INDEX_NTH(vec, nth, value, cmp)
Get the nth index from a vector that matches the given comparison.
#define AST_VECTOR_INSERT_AT(vec, idx, elem)
Insert an element at a specific position in a vector, growing the vector if needed.
#define AST_VECTOR_RW_WRLOCK(vec)
Obtain write lock on vector.
#define AST_VECTOR_REMOVE_CMP_ORDERED(vec, value, cmp, cleanup)
Remove an element from a vector that matches the given comparison while maintaining order.
#define AST_VECTOR_REMOVE_ELEM_ORDERED(vec, elem, cleanup)
Remove an element from a vector while maintaining order.
#define AST_VECTOR_RW_UNLOCK(vec)
Unlock vector.
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
#define AST_VECTOR_GET_CMP(vec, value, cmp)
Get an element from a vector that matches the given comparison.
#define AST_VECTOR_RW_FREE(vec)
Deallocates this locked vector.
#define AST_VECTOR_RW_WRLOCK_TIMED(vec, timespec)
Try to obtain write lock on vector failing after timeout if unable.
#define AST_VECTOR_ELEM_DEFAULT_CMP(elem, value)
Default comparator for AST_VECTOR_REMOVE_ELEM_UNORDERED()
#define AST_VECTOR_ADD_SORTED(vec, elem, cmp)
Add an element into a sorted vector.
#define AST_VECTOR_REMOVE_UNORDERED(vec, idx)
Remove an element from an unordered vector by index.
#define AST_VECTOR_DEFAULT(vec, size, value)
Default a vector up to size with the given value.
#define AST_VECTOR_RW(name, type)
Define a vector structure with a read/write lock.
#define AST_VECTOR_RW_RDLOCK_TRY(vec)
Try to obtain read lock on vector failing immediately if unable.
#define AST_VECTOR_CALLBACK_MULTIPLE(vec, callback,...)
Execute a callback on every element in a vector returning the matching elements in a new vector.
#define AST_VECTOR_CALLBACK(vec, callback, default_value,...)
Execute a callback on every element in a vector returning the first matched.
#define AST_VECTOR_RW_RDLOCK_TIMED(vec, timespec)
Try to obtain read lock on vector failing after timeout if unable.
#define AST_VECTOR_RW_RDLOCK(vec)
Obtain read lock on vector.
#define AST_VECTOR_PTR_FREE(vec)
Deallocates this vector pointer.
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
#define AST_VECTOR_MATCH_ALL(element)
Default callback for AST_VECTOR_CALLBACK()
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
#define AST_VECTOR(name, type)
Define a vector structure.
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
#define AST_VECTOR_RW_INIT(vec, size)
Initialize a vector with a read/write lock.