Go to the documentation of this file.
26 #elif defined(_MSC_VER)
41 assert_true(
strprefix(
"123456",
"123456"));
50 #define teststr1 "one"
51 #define teststr2 "two"
52 #define teststr3 "three"
53 #define teststr4 "four"
55 #define assert_buf_equals_str(buf, str) \
56 assert_int_equal(BLEN(buf), strlen(str)); \
57 assert_memory_equal(BPTR(buf), str, BLEN(buf));
174 assert_int_equal(bl_zerolen->
size, 1);
187 assert_int_equal(bl_emptybuffers->
size, 1);
189 assert_int_equal(
BLEN(buf), 0);
198 assert_ptr_equal(gc.
list + 1, buf.
data);
200 assert_null(gc.
list);
217 assert_ptr_equal(e + 1, buf3.
data);
218 assert_ptr_equal(e->
next + 1, buf2.
data);
223 assert_non_null(gc.
list);
227 assert_ptr_not_equal(e + 1, buf2.
data);
237 const struct CMUnitTest tests[] = {
264 return cmocka_run_group_tests_name(
"buffer", tests, NULL, NULL);
struct gc_entry * list
First element of the linked list of gc_entry structures.
static void test_buffer_list_aggregate_separator_all(void **state)
struct buffer_list * empty_buffers
static void test_buffer_free_gc_two(void **state)
#define assert_buf_equals_str(buf, str)
static struct gc_arena gc_new(void)
struct gc_entry * next
Pointer to the next item in the linked list.
struct buffer alloc_buf_gc(size_t size, struct gc_arena *gc)
Garbage collection entry for one dynamically allocated block of memory.
struct buffer * buffer_list_peek(struct buffer_list *ol)
Retrieve the head buffer.
void buffer_list_aggregate_separator(struct buffer_list *bl, const size_t max_len, const char *sep)
Aggregates as many buffers as possible from bl in a new buffer of maximum length max_len .
struct buffer_list * empty
static void test_buffer_list_aggregate_separator_zerolen(void **state)
struct buffer_entry * buffer_list_push_data(struct buffer_list *ol, const void *data, size_t size)
Allocates and appends a new buffer containing data of length size.
static void test_buffer_strprefix(void **state)
static void test_buffer_list_aggregate_separator_emptybuffers(void **state)
void buffer_list_push(struct buffer_list *ol, const char *str)
Allocates and appends a new buffer containing str as data to ol.
struct buffer_list * zero_length_strings
Wrapper structure for dynamically allocated memory.
struct buffer_list * buffer_list_new(void)
Allocate an empty buffer list of capacity max_size.
Garbage collection arena used to keep track of dynamically allocated memory.
static void free_buf_gc(struct buffer *buf, struct gc_arena *gc)
static void test_buffer_free_gc_one(void **state)
static bool strprefix(const char *str, const char *prefix)
Return true iff str starts with prefix.
static void gc_free(struct gc_arena *a)
static void test_buffer_list_aggregate_separator_nosep(void **state)
static void test_buffer_list_aggregate_separator_empty(void **state)
void buffer_list_free(struct buffer_list *ol)
Frees a buffer list and all the buffers in it.
struct buffer_list * one_two_three
static int test_buffer_list_setup(void **state)
static void test_buffer_list_aggregate_separator_noop(void **state)
static int test_buffer_list_teardown(void **state)
struct buffer_entry * head
static void test_buffer_list_aggregate_separator_two(void **state)
uint8_t * data
Pointer to the allocated memory.