56 #include <sys/resource.h>
109 string.data.s =
"Key1:Hello,Key2:world,Key3:and,Key4:anyone,Key5:else,Key6:in,Key7:the,Key8:universe";
150 assert_non_null(
GET_ARG(&dst,
"key5"));
151 assert_non_null(
GET_ARG(&dst,
"key1"));
152 assert_non_null(
GET_ARG(&dst,
"key3"));
153 assert_non_null(
GET_ARG(&dst,
"key7"));
154 assert_non_null(
GET_ARG(&dst,
"key9"));
178 string.data.s =
"Key1:Hello,Key2:world,Key3:and,Key4:anyone,Key5:else,Key6:in,Key7:the,Key8:universe";
183 assert_true(copy_var.
data.b);
203 assert_int_equal(
var.
data.ui64, 0);
207 string.data.s =
"Key1:Hello,Key2:world,Key3:and,Key4:anyone,Key5:else,Key6:in,Key7:the,Key8:universe";
212 assert_int_equal(copy_var.
data.ui64, 8);
237 string.data.s =
"Key1:Hello,Key2:world,Key3:and,Key4:anyone,Key5:else,Key6:in,Key7:the,Key8:universe";
264 assert_ptr_not_equal(
var.
data.s, NULL);
265 assert_int_equal(strlen(
var.
data.s), 0);
268 string.data.s =
"Key1:Hello,Key2:world,Key3:and,Key4:anyone,Key5:else,Key6:in,Key7:the,Key8:universe";
274 assert_string_equal(copy_var.
data.s,
string.data.s);
314 assert_ptr_equal(
htable, NULL);
318 assert_ptr_equal(
htable, NULL);
320 assert_ptr_equal(consthtable, NULL);
323 string.data.s =
"Key1:Hello,Key2:world,Key3:and,Key4:anyone,Key5:else,Key6:in,Key7:the,Key8:universe";
327 assert_ptr_not_equal(
htable, NULL);
330 assert_ptr_not_equal(consthtable, NULL);
333 assert_non_null(item);
335 assert_non_null(item);
358 assert_true(result == 0);
362 assert_true(result > 0);
364 assert_true(result < 0);
368 assert_true(result == 0);
372 assert_true(result > 0);
376 assert_true(result < 0);
381 assert_true(result == 0);
389 assert_true(result == 0);
394 assert_true(result == 0);
399 assert_true(result != 0);
402 assert_true(result != 0);
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(consttable, NULL);
456 assert_ptr_not_equal(item, NULL);
462 assert_ptr_not_equal(item, NULL);
468 assert_ptr_equal(item, NULL);
471 assert_ptr_not_equal(consttable, NULL);
486 assert_ptr_not_equal(item, NULL);
488 assert_ptr_equal(item, NULL);
Ambiorix variant API header file.
#define cstring_t
Convenience macro.
#define amxc_var_from_htable_it(ht_it)
Get the variant pointer from an amxc htable iterator.
int amxc_htable_init(amxc_htable_t *const htable, const size_t reserve)
Initializes a hash table.
void amxc_htable_delete(amxc_htable_t **htable, amxc_htable_it_delete_t func)
Frees the previously allocated hash table.
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.
int amxc_htable_insert(amxc_htable_t *const htable, const char *const key, amxc_htable_it_t *const it)
Inserts an item in the hash table.
#define amxc_htable_for_each(it, htable)
Loops over items in the hash table.
void amxc_htable_clean(amxc_htable_t *const htable, amxc_htable_it_delete_t func)
Removes all items from the hash table.
size_t amxc_llist_size(const amxc_llist_t *const llist)
Calculates the size of the linked list.
bool amxc_llist_is_empty(const amxc_llist_t *const llist)
Checks that the linked list is empty.
#define AMXC_VAR_FLAG_DEFAULT
The default flag, do not copy, use variant as is.
#define AMXC_VAR_FLAG_COPY
Copy the variant, creates a new variant, leaves the source variant untouched.
#define AMXC_VAR_FLAG_AUTO_ADD
Add none existing variants to composite variants. This flag can be used with amxc_var_set_path and am...
int amxc_var_set_cstring_t(amxc_var_t *const var, const char *const val)
Setter helper function.
void variant_htable_it_free(const char *key, amxc_htable_it_t *it)
Helper functions, can be used as delete function for htable.
#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_BOOL
Boolean variant id.
#define AMXC_VAR_ID_LIST
Ambiorix Linked List variant id.
#define AMXC_VAR_ID_HTABLE
Ambiorix Hash Table variant id.
#define GET_ARG(a, n)
Convenience macro for getting variant out of a composite variant by key.
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 int amxc_var_set_path(amxc_var_t *const var, const char *const path, amxc_var_t *data, const int flags)
Sets 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_new(amxc_var_t **var)
Allocates a variant and initializes it to the null variant 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.
amxc_var_t * amxc_var_get_index(const amxc_var_t *const var, const int64_t index, const int flags)
Get a reference to a part of composed variant using an index.
#define amxc_var_set(type, var, data)
Convenience macro for setting a value in a 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]
static amxc_htable_t * htable
void test_variant_htable_add_new_key(UNUSED void **state)
void test_variant_htable_compare(UNUSED void **state)
void test_variant_htable_init(UNUSED void **state)
void test_variant_htable_set_get(UNUSED void **state)
void test_variant_htable_move(UNUSED void **state)
void test_variant_htable_convert_to_integer(UNUSED void **state)
void test_variant_htable_convert_to_string_should_not_segfault(UNUSED void **state)
void test_variant_htable_convert_to_list(UNUSED void **state)
void test_variant_htable_copy(UNUSED void **state)
void test_variant_htable_convert_to_string(UNUSED void **state)
void test_variant_htable_add_new_key_duplicate(UNUSED void **state)
void test_variant_htable_convert_to_bool(UNUSED void **state)
void test_variant_htable_add_new(UNUSED void **state)