56 #include <sys/resource.h>
87 string.data.s = strdup(
"");
94 string.data.s = strdup(
"Hello,world,and,anyone,else,in,the,universe");
102 list = ©_var.
data.vl;
154 string.data.s = strdup(
"Hello,world,and,anyone,else,in,the,universe");
159 assert_true(copy_var.
data.b);
180 assert_int_equal(
var.
data.ui64, 0);
184 string.data.s = strdup(
"Hello,world,and,anyone,else,in,the,universe");
189 assert_int_equal(copy_var.
data.ui64, 8);
215 string.data.s = strdup(
"Hello,world,and,anyone,else,in,the,universe");
243 assert_ptr_equal(
var.
data.s, NULL);
247 string.data.s = strdup(
"Hello,world,and,anyone,else,in,the,universe");
253 assert_string_equal(copy_var.
data.s,
"Hello,world,and,anyone,else,in,the,universe");
259 assert_string_equal(copy_var.
data.s,
"Hello,world,and,anyone,else,in,the,universe");
265 assert_string_equal(copy_var.
data.s,
"Hello world and anyone else in the universe");
282 assert_ptr_equal(list, NULL);
286 assert_ptr_equal(list, NULL);
288 assert_ptr_equal(constlist, NULL);
291 string.data.s = strdup(
"Hello,world,and,anyone,else,in,the,universe");
295 assert_ptr_not_equal(list, NULL);
298 assert_ptr_not_equal(constlist, NULL);
319 assert_true(result == 0);
323 assert_true(result > 0);
325 assert_true(result < 0);
329 assert_true(result == 0);
333 assert_true(result > 0);
337 assert_true(result < 0);
342 assert_true(result == 0);
349 assert_true(result != 0);
354 assert_true(result == 0);
357 assert_non_null(list1);
359 assert_non_null(list2);
361 assert_true(result == 0);
365 assert_true(result > 0);
369 assert_true(result == 0);
387 assert_ptr_not_equal(item, NULL);
393 assert_ptr_not_equal(item, NULL);
399 assert_ptr_equal(item, NULL);
402 assert_ptr_not_equal(constlist, NULL);
422 assert_ptr_not_equal(item, NULL);
428 assert_ptr_not_equal(item, NULL);
434 assert_ptr_equal(item, NULL);
437 assert_ptr_not_equal(constlist, NULL);
456 assert_ptr_not_equal(item, NULL);
Ambiorix variant API header file.
#define cstring_t
Convenience macro.
#define amxc_var_from_llist_it(ll_it)
Get the variant pointer from an amxc linked list iterator.
AMXC_INLINE size_t amxc_htable_size(const amxc_htable_t *const htable)
Calculates the size of the hash table.
AMXC_INLINE bool amxc_htable_is_empty(const amxc_htable_t *const htable)
Checks that the hash table is empty.
void amxc_llist_delete(amxc_llist_t **llist, amxc_llist_it_delete_t func)
Frees the previously allocated linked list.
size_t amxc_llist_size(const amxc_llist_t *const llist)
Calculates the size of the linked list.
int amxc_llist_init(amxc_llist_t *const llist)
Initializes a linked list.
bool amxc_llist_is_empty(const amxc_llist_t *const llist)
Checks that the linked list is empty.
void amxc_llist_clean(amxc_llist_t *const llist, amxc_llist_it_delete_t func)
Removes all items from the linked list.
#define amxc_llist_for_each(it, list)
Loops over the list from head to tail.
#define AMXC_VAR_FLAG_DEFAULT
The default flag, do not copy, use variant as is.
void variant_list_it_free(amxc_llist_it_t *it)
Helper functions, can be used as delete function for linked lists.
#define AMXC_VAR_ID_UINT32
Unsigned 32 bit integer variant id.
#define AMXC_VAR_ID_CUSTOM_BASE
Base variant id for custom variants.
#define AMXC_VAR_ID_NULL
Null variant type id (aka void)
#define AMXC_VAR_ID_CSTRING
C-string variant id (aka char *), null terminated string.
#define AMXC_VAR_ID_UINT64
Unsigned 64 bit integer variant id.
#define AMXC_VAR_ID_SSV_STRING
Space Separated Values string variant id.
#define AMXC_VAR_ID_BOOL
Boolean variant id.
#define AMXC_VAR_ID_CSV_STRING
Comma Separated Values string variant id.
#define AMXC_VAR_ID_LIST
Ambiorix Linked List variant id.
#define AMXC_VAR_ID_HTABLE
Ambiorix Hash Table variant id.
int amxc_var_move(amxc_var_t *const dest, amxc_var_t *const src)
Moves the type and data from one variant (source) in another variant (destination).
uint32_t amxc_var_type_of(const amxc_var_t *const var)
Gets the variant type id of a variant.
#define amxc_var_add_key(type, var, key, data)
Convenience macro for adding a variant to composite variant type.
#define amxc_var_add(type, var, data)
Convenience macro for adding a variant to composite variant type.
AMXC_INLINE bool amxc_var_is_null(const amxc_var_t *const var)
Checks if the given variant is of the "null" type.
int amxc_var_set_type(amxc_var_t *const var, const uint32_t type)
Change the variant data type.
amxc_var_t * amxc_var_get_path(const amxc_var_t *const var, const char *const path, const int flags)
Retrieves the variant at the given path of a composite variant.
#define amxc_var_dyncast(type, var)
Dynamic cast a variant to a certain type.
int amxc_var_init(amxc_var_t *const var)
Initializes a variant.
int amxc_var_copy(amxc_var_t *const dest, const amxc_var_t *const src)
Copy the type and data from one variant (source) in another variant (destination).
void amxc_var_clean(amxc_var_t *const var)
Clean-up and reset variant.
int amxc_var_convert(amxc_var_t *const dest, const amxc_var_t *src, const uint32_t type_id)
Converts one variant (source) to another variant(destination) using the specified variant type id.
int amxc_var_compare(const amxc_var_t *const var1, const amxc_var_t *const var2, int *const result)
Compares two variants.
#define amxc_var_constcast(type, var)
Takes the content from a variant.
The hash table structure.
The linked list structure.
The variant struct definition.
static amxc_htable_it_t it[2000]
void test_variant_list_convert_to_htable(UNUSED void **state)
void test_variant_llist_get_path(UNUSED void **state)
void test_variant_list_copy(UNUSED void **state)
void test_variant_list_convert_to_integer(UNUSED void **state)
void test_variant_llist_add_new(UNUSED void **state)
void test_variant_llist_set_get(UNUSED void **state)
void test_variant_list_convert_to_string(UNUSED void **state)
void test_variant_llist_add_new_key(UNUSED void **state)
void test_variant_list_convert_to_bool(UNUSED void **state)
void test_variant_llist_compare(UNUSED void **state)
void test_variant_list_move(UNUSED void **state)