diff --git a/autogen.py b/autogen.py index 8c0ba1d..924c70b 100644 --- a/autogen.py +++ b/autogen.py @@ -86,7 +86,14 @@ for data in collections: file = open(f'{OUTPUT_DIR}/{data["sname"]}.c', 'w') - file.write(f'#include {data["h"]}\n{match.group("code")}') + file.write( + f'''#ifndef CMC_TEST_SRC_{data['t']} + #define CMC_TEST_SRC_{data['t']} + + #include {data["h"]}\n{match.group("code")} + + #endif /* CMC_TEST_SRC_{data['t']} */ + ''') file.flush() file.close() diff --git a/tests/main/src/bitset.c b/tests/main/src/bitset.c index 07c7094..fdd081c 100644 --- a/tests/main/src/bitset.c +++ b/tests/main/src/bitset.c @@ -1,3 +1,6 @@ +#ifndef CMC_TEST_SRC_BITSET +#define CMC_TEST_SRC_BITSET + #include "cmc/bitset.h" struct bitset @@ -331,3 +334,5 @@ _Bool bs_impl_resize(struct bitset *_bitset_, size_t n_bits, _Bool do_resize) _bitset_->flag = cmc_flags.OK; return 1; } + +#endif /* CMC_TEST_SRC_BITSET */ diff --git a/tests/main/src/deque.c b/tests/main/src/deque.c index b267482..ba1e982 100644 --- a/tests/main/src/deque.c +++ b/tests/main/src/deque.c @@ -1,3 +1,6 @@ +#ifndef CMC_TEST_SRC_DEQUE +#define CMC_TEST_SRC_DEQUE + #include "cmc/deque.h" struct deque @@ -565,3 +568,5 @@ size_t d_iter_index(struct deque_iter *iter) { return iter->index; } + +#endif /* CMC_TEST_SRC_DEQUE */ diff --git a/tests/main/src/hashbidimap.c b/tests/main/src/hashbidimap.c index 7caeb61..d8e98b8 100644 --- a/tests/main/src/hashbidimap.c +++ b/tests/main/src/hashbidimap.c @@ -1,3 +1,6 @@ +#ifndef CMC_TEST_SRC_HASHBIDIMAP +#define CMC_TEST_SRC_HASHBIDIMAP + #include "cmc/hashbidimap.h" struct hashbidimap @@ -973,3 +976,5 @@ static struct hashbidimap_iter hbm_impl_it_end(struct hashbidimap *_map_) hbm_iter_to_end(&iter); return iter; } + +#endif /* CMC_TEST_SRC_HASHBIDIMAP */ diff --git a/tests/main/src/hashmap.c b/tests/main/src/hashmap.c index 462ca88..b771ab4 100644 --- a/tests/main/src/hashmap.c +++ b/tests/main/src/hashmap.c @@ -1,3 +1,6 @@ +#ifndef CMC_TEST_SRC_HASHMAP +#define CMC_TEST_SRC_HASHMAP + #include "cmc/hashmap.h" struct hashmap @@ -842,3 +845,5 @@ static size_t hm_impl_calculate_size(size_t required) i++; return cmc_hashtable_primes[i]; } + +#endif /* CMC_TEST_SRC_HASHMAP */ diff --git a/tests/main/src/hashmultimap.c b/tests/main/src/hashmultimap.c index 0163322..ac1471e 100644 --- a/tests/main/src/hashmultimap.c +++ b/tests/main/src/hashmultimap.c @@ -1,3 +1,6 @@ +#ifndef CMC_TEST_SRC_HASHMULTIMAP +#define CMC_TEST_SRC_HASHMULTIMAP + #include "cmc/hashmultimap.h" struct hashmultimap @@ -1009,3 +1012,5 @@ size_t hmm_impl_calculate_size(size_t required) i++; return cmc_hashtable_primes[i]; } + +#endif /* CMC_TEST_SRC_HASHMULTIMAP */ diff --git a/tests/main/src/hashmultiset.c b/tests/main/src/hashmultiset.c index a8e2616..7533b8c 100644 --- a/tests/main/src/hashmultiset.c +++ b/tests/main/src/hashmultiset.c @@ -1,3 +1,6 @@ +#ifndef CMC_TEST_SRC_HASHMULTISET +#define CMC_TEST_SRC_HASHMULTISET + #include "cmc/hashmultiset.h" struct hashmultiset @@ -1056,3 +1059,5 @@ static size_t hms_impl_calculate_size(size_t required) i++; return cmc_hashtable_primes[i]; } + +#endif /* CMC_TEST_SRC_HASHMULTISET */ diff --git a/tests/main/src/hashset.c b/tests/main/src/hashset.c index ae8728e..856920d 100644 --- a/tests/main/src/hashset.c +++ b/tests/main/src/hashset.c @@ -1,3 +1,6 @@ +#ifndef CMC_TEST_SRC_HASHSET +#define CMC_TEST_SRC_HASHSET + #include "cmc/hashset.h" struct hashset @@ -848,3 +851,5 @@ static size_t hs_impl_calculate_size(size_t required) i++; return cmc_hashtable_primes[i]; } + +#endif /* CMC_TEST_SRC_HASHSET */ diff --git a/tests/main/src/heap.c b/tests/main/src/heap.c index 87d59c8..972af1d 100644 --- a/tests/main/src/heap.c +++ b/tests/main/src/heap.c @@ -1,3 +1,6 @@ +#ifndef CMC_TEST_SRC_HEAP +#define CMC_TEST_SRC_HEAP + #include "cmc/heap.h" struct heap @@ -491,3 +494,5 @@ static void h_impl_float_down(struct heap *_heap_, size_t index) break; } } + +#endif /* CMC_TEST_SRC_HEAP */ diff --git a/tests/main/src/intervalheap.c b/tests/main/src/intervalheap.c index f1eefb1..568ac19 100644 --- a/tests/main/src/intervalheap.c +++ b/tests/main/src/intervalheap.c @@ -1,3 +1,6 @@ +#ifndef CMC_TEST_SRC_INTERVALHEAP +#define CMC_TEST_SRC_INTERVALHEAP + #include "cmc/intervalheap.h" struct intervalheap @@ -756,3 +759,5 @@ static void ih_impl_float_down_min(struct intervalheap *_heap_) curr_node = child_node; } } + +#endif /* CMC_TEST_SRC_INTERVALHEAP */ diff --git a/tests/main/src/linkedlist.c b/tests/main/src/linkedlist.c index 52b12c2..f5d3d6a 100644 --- a/tests/main/src/linkedlist.c +++ b/tests/main/src/linkedlist.c @@ -1,3 +1,6 @@ +#ifndef CMC_TEST_SRC_LINKEDLIST +#define CMC_TEST_SRC_LINKEDLIST + #include "cmc/linkedlist.h" struct linkedlist @@ -760,3 +763,5 @@ struct linkedlist_node *ll_iter_node(struct linkedlist_iter *iter) { return iter->cursor; } + +#endif /* CMC_TEST_SRC_LINKEDLIST */ diff --git a/tests/main/src/list.c b/tests/main/src/list.c index 65a0922..221171c 100644 --- a/tests/main/src/list.c +++ b/tests/main/src/list.c @@ -1,3 +1,6 @@ +#ifndef CMC_TEST_SRC_LIST +#define CMC_TEST_SRC_LIST + #include "cmc/list.h" struct list @@ -713,3 +716,5 @@ size_t l_iter_index(struct list_iter *iter) { return iter->cursor; } + +#endif /* CMC_TEST_SRC_LIST */ diff --git a/tests/main/src/multiset.c b/tests/main/src/multiset.c deleted file mode 100644 index 6ee26c8..0000000 --- a/tests/main/src/multiset.c +++ /dev/null @@ -1,1043 +0,0 @@ -#include "cmc/multiset.h" - -struct multiset -{ - struct multiset_entry *buffer; - size_t capacity; - size_t count; - size_t cardinality; - double load; - int flag; - struct multiset_fval *f_val; - struct cmc_alloc_node *alloc; - struct cmc_callbacks *callbacks; - struct multiset_iter (*it_start)(struct multiset *); - struct multiset_iter (*it_end)(struct multiset *); -}; -struct multiset_entry -{ - size_t value; - size_t multiplicity; - size_t dist; - enum cmc_entry_state state; -}; -struct multiset_fval -{ - int (*cmp)(size_t, size_t); - size_t (*cpy)(size_t); - _Bool (*str)(FILE *, size_t); - void (*free)(size_t); - size_t (*hash)(size_t); - int (*pri)(size_t, size_t); -}; -struct multiset_iter -{ - struct multiset *target; - size_t cursor; - size_t index; - size_t first; - size_t last; - _Bool start; - _Bool end; -}; -struct multiset *ms_new(size_t capacity, double load, - struct multiset_fval *f_val); -struct multiset *ms_new_custom(size_t capacity, double load, - struct multiset_fval *f_val, - struct cmc_alloc_node *alloc, - struct cmc_callbacks *callbacks); -void ms_clear(struct multiset *_set_); -void ms_free(struct multiset *_set_); -void ms_customize(struct multiset *_set_, struct cmc_alloc_node *alloc, - struct cmc_callbacks *callbacks); -_Bool ms_insert(struct multiset *_set_, size_t value); -_Bool ms_insert_many(struct multiset *_set_, size_t value, size_t count); -_Bool ms_update(struct multiset *_set_, size_t value, size_t multiplicity); -_Bool ms_remove(struct multiset *_set_, size_t value); -size_t ms_remove_all(struct multiset *_set_, size_t value); -_Bool ms_max(struct multiset *_set_, size_t *value); -_Bool ms_min(struct multiset *_set_, size_t *value); -size_t ms_multiplicity_of(struct multiset *_set_, size_t value); -_Bool ms_contains(struct multiset *_set_, size_t value); -_Bool ms_empty(struct multiset *_set_); -_Bool ms_full(struct multiset *_set_); -size_t ms_count(struct multiset *_set_); -size_t ms_cardinality(struct multiset *_set_); -size_t ms_capacity(struct multiset *_set_); -double ms_load(struct multiset *_set_); -int ms_flag(struct multiset *_set_); -_Bool ms_resize(struct multiset *_set_, size_t capacity); -struct multiset *ms_copy_of(struct multiset *_set_); -_Bool ms_equals(struct multiset *_set1_, struct multiset *_set2_); -struct cmc_string ms_to_string(struct multiset *_set_); -_Bool ms_print(struct multiset *_set_, FILE *fptr); -struct multiset *ms_union(struct multiset *_set1_, struct multiset *_set2_); -struct multiset *ms_intersection(struct multiset *_set1_, - struct multiset *_set2_); -struct multiset *ms_difference(struct multiset *_set1_, - struct multiset *_set2_); -struct multiset *ms_summation(struct multiset *_set1_, struct multiset *_set2_); -struct multiset *ms_symmetric_difference(struct multiset *_set1_, - struct multiset *_set2_); -_Bool ms_is_subset(struct multiset *_set1_, struct multiset *_set2_); -_Bool ms_is_superset(struct multiset *_set1_, struct multiset *_set2_); -_Bool ms_is_proper_subset(struct multiset *_set1_, struct multiset *_set2_); -_Bool ms_is_proper_superset(struct multiset *_set1_, struct multiset *_set2_); -_Bool ms_is_disjointset(struct multiset *_set1_, struct multiset *_set2_); -struct multiset_iter *ms_iter_new(struct multiset *target); -void ms_iter_free(struct multiset_iter *iter); -void ms_iter_init(struct multiset_iter *iter, struct multiset *target); -_Bool ms_iter_start(struct multiset_iter *iter); -_Bool ms_iter_end(struct multiset_iter *iter); -void ms_iter_to_start(struct multiset_iter *iter); -void ms_iter_to_end(struct multiset_iter *iter); -_Bool ms_iter_next(struct multiset_iter *iter); -_Bool ms_iter_prev(struct multiset_iter *iter); -_Bool ms_iter_advance(struct multiset_iter *iter, size_t steps); -_Bool ms_iter_rewind(struct multiset_iter *iter, size_t steps); -_Bool ms_iter_go_to(struct multiset_iter *iter, size_t index); -size_t ms_iter_value(struct multiset_iter *iter); -size_t ms_iter_multiplicity(struct multiset_iter *iter); -size_t ms_iter_index(struct multiset_iter *iter); -static size_t ms_impl_multiplicity_of(struct multiset *_set_, size_t value); -static struct multiset_entry *ms_impl_insert_and_return(struct multiset *_set_, - size_t value, - _Bool *new_node); -static struct multiset_entry *ms_impl_get_entry(struct multiset *_set_, - size_t value); -static size_t ms_impl_calculate_size(size_t required); -static struct multiset_iter ms_impl_it_start(struct multiset *_set_); -static struct multiset_iter ms_impl_it_end(struct multiset *_set_); -struct multiset *ms_new(size_t capacity, double load, - struct multiset_fval *f_val) -{ - struct cmc_alloc_node *alloc = &cmc_alloc_node_default; - if (capacity == 0 || load <= 0 || load >= 1) - return ((void *)0); - if (capacity >= 0xffffffffffffffffULL * load) - return ((void *)0); - if (!f_val) - return ((void *)0); - size_t real_capacity = ms_impl_calculate_size(capacity / load); - struct multiset *_set_ = alloc->malloc(sizeof(struct multiset)); - if (!_set_) - return ((void *)0); - _set_->buffer = alloc->calloc(real_capacity, sizeof(struct multiset_entry)); - if (!_set_->buffer) - { - alloc->free(_set_); - return ((void *)0); - } - _set_->count = 0; - _set_->cardinality = 0; - _set_->capacity = real_capacity; - _set_->load = load; - _set_->flag = cmc_flags.OK; - _set_->f_val = f_val; - _set_->alloc = alloc; - _set_->callbacks = ((void *)0); - _set_->it_start = ms_impl_it_start; - _set_->it_end = ms_impl_it_end; - return _set_; -} -struct multiset *ms_new_custom(size_t capacity, double load, - struct multiset_fval *f_val, - struct cmc_alloc_node *alloc, - struct cmc_callbacks *callbacks) -{ - if (capacity == 0 || load <= 0 || load >= 1) - return ((void *)0); - if (capacity >= 0xffffffffffffffffULL * load) - return ((void *)0); - if (!f_val) - return ((void *)0); - size_t real_capacity = ms_impl_calculate_size(capacity / load); - if (!alloc) - alloc = &cmc_alloc_node_default; - struct multiset *_set_ = alloc->malloc(sizeof(struct multiset)); - if (!_set_) - return ((void *)0); - _set_->buffer = alloc->calloc(real_capacity, sizeof(struct multiset_entry)); - if (!_set_->buffer) - { - alloc->free(_set_); - return ((void *)0); - } - _set_->count = 0; - _set_->cardinality = 0; - _set_->capacity = real_capacity; - _set_->load = load; - _set_->flag = cmc_flags.OK; - _set_->f_val = f_val; - _set_->alloc = alloc; - _set_->callbacks = callbacks; - _set_->it_start = ms_impl_it_start; - _set_->it_end = ms_impl_it_end; - return _set_; -} -void ms_clear(struct multiset *_set_) -{ - if (_set_->f_val->free) - { - for (size_t i = 0; i < _set_->capacity; i++) - { - struct multiset_entry *entry = &(_set_->buffer[i]); - if (entry->state == CMC_ES_FILLED) - { - _set_->f_val->free(entry->value); - } - } - } - memset(_set_->buffer, 0, sizeof(struct multiset_entry) * _set_->capacity); - _set_->count = 0; - _set_->flag = cmc_flags.OK; -} -void ms_free(struct multiset *_set_) -{ - if (_set_->f_val->free) - { - for (size_t i = 0; i < _set_->capacity; i++) - { - struct multiset_entry *entry = &(_set_->buffer[i]); - if (entry->state == CMC_ES_FILLED) - { - _set_->f_val->free(entry->value); - } - } - } - _set_->alloc->free(_set_->buffer); - _set_->alloc->free(_set_); -} -void ms_customize(struct multiset *_set_, struct cmc_alloc_node *alloc, - struct cmc_callbacks *callbacks) -{ - if (!alloc) - _set_->alloc = &cmc_alloc_node_default; - else - _set_->alloc = alloc; - _set_->callbacks = callbacks; - _set_->flag = cmc_flags.OK; -} -_Bool ms_insert(struct multiset *_set_, size_t value) -{ - _Bool new_node; - struct multiset_entry *entry = - ms_impl_insert_and_return(_set_, value, &new_node); - if (!entry) - { - _set_->flag = cmc_flags.ERROR; - return 0; - } - if (!new_node) - entry->multiplicity++; - _set_->cardinality++; - _set_->flag = cmc_flags.OK; - if (_set_->callbacks && _set_->callbacks->create) - _set_->callbacks->create(); - return 1; -} -_Bool ms_insert_many(struct multiset *_set_, size_t value, size_t count) -{ - if (count == 0) - goto success; - _Bool new_node; - struct multiset_entry *entry = - ms_impl_insert_and_return(_set_, value, &new_node); - if (!entry) - { - _set_->flag = cmc_flags.ERROR; - return 0; - } - if (new_node) - entry->multiplicity = count; - else - entry->multiplicity += count; - _set_->cardinality += count; -success: - _set_->flag = cmc_flags.OK; - if (_set_->callbacks && _set_->callbacks->create) - _set_->callbacks->create(); - return 1; -} -_Bool ms_update(struct multiset *_set_, size_t value, size_t multiplicity) -{ - if (multiplicity == 0) - { - struct multiset_entry *result = ms_impl_get_entry(_set_, value); - if (!result) - goto success; - _set_->count--; - _set_->cardinality -= result->multiplicity; - result->value = (size_t){ 0 }; - result->multiplicity = 0; - result->dist = 0; - result->state = CMC_ES_DELETED; - goto success; - } - _Bool new_node; - struct multiset_entry *entry = - ms_impl_insert_and_return(_set_, value, &new_node); - if (!entry) - return 0; - if (new_node) - _set_->cardinality++; - _set_->cardinality = - (_set_->cardinality - entry->multiplicity) + multiplicity; - entry->multiplicity = multiplicity; -success: - _set_->flag = cmc_flags.OK; - if (_set_->callbacks && _set_->callbacks->update) - _set_->callbacks->update(); - return 1; -} -_Bool ms_remove(struct multiset *_set_, size_t value) -{ - if (ms_empty(_set_)) - { - _set_->flag = cmc_flags.EMPTY; - return 0; - } - struct multiset_entry *result = ms_impl_get_entry(_set_, value); - if (!result) - { - _set_->flag = cmc_flags.NOT_FOUND; - return 0; - } - if (result->multiplicity > 1) - result->multiplicity--; - else - { - result->value = (size_t){ 0 }; - result->multiplicity = 0; - result->dist = 0; - result->state = CMC_ES_DELETED; - _set_->count--; - } - _set_->cardinality--; - _set_->flag = cmc_flags.OK; - if (_set_->callbacks && _set_->callbacks->delete) - _set_->callbacks->delete (); - return 1; -} -size_t ms_remove_all(struct multiset *_set_, size_t value) -{ - if (ms_empty(_set_)) - { - _set_->flag = cmc_flags.EMPTY; - return 0; - } - struct multiset_entry *result = ms_impl_get_entry(_set_, value); - if (!result) - { - _set_->flag = cmc_flags.NOT_FOUND; - return 0; - } - size_t removed = result->multiplicity; - result->value = (size_t){ 0 }; - result->multiplicity = 0; - result->dist = 0; - result->state = CMC_ES_DELETED; - _set_->count--; - _set_->cardinality -= removed; - _set_->flag = cmc_flags.OK; - if (_set_->callbacks && _set_->callbacks->delete) - _set_->callbacks->delete (); - return removed; -} -_Bool ms_max(struct multiset *_set_, size_t *value) -{ - if (ms_empty(_set_)) - { - _set_->flag = cmc_flags.EMPTY; - return 0; - } - size_t max_val; - struct multiset_iter iter; - for (ms_iter_init(&iter, _set_); !ms_iter_end(&iter); ms_iter_next(&iter)) - { - size_t result = ms_iter_value(&iter); - size_t index = ms_iter_index(&iter); - if (index == 0) - max_val = result; - else if (_set_->f_val->cmp(result, max_val) > 0) - max_val = result; - } - if (value) - *value = max_val; - _set_->flag = cmc_flags.OK; - if (_set_->callbacks && _set_->callbacks->read) - _set_->callbacks->read(); - return 1; -} -_Bool ms_min(struct multiset *_set_, size_t *value) -{ - if (ms_empty(_set_)) - { - _set_->flag = cmc_flags.EMPTY; - return 0; - } - size_t min_val; - struct multiset_iter iter; - for (ms_iter_init(&iter, _set_); !ms_iter_end(&iter); ms_iter_next(&iter)) - { - size_t result = ms_iter_value(&iter); - size_t index = ms_iter_index(&iter); - if (index == 0) - min_val = result; - else if (_set_->f_val->cmp(result, min_val) < 0) - min_val = result; - } - if (value) - *value = min_val; - _set_->flag = cmc_flags.OK; - if (_set_->callbacks && _set_->callbacks->read) - _set_->callbacks->read(); - return 1; -} -size_t ms_multiplicity_of(struct multiset *_set_, size_t value) -{ - struct multiset_entry *entry = ms_impl_get_entry(_set_, value); - _set_->flag = cmc_flags.OK; - if (_set_->callbacks && _set_->callbacks->read) - _set_->callbacks->read(); - if (!entry) - return 0; - return entry->multiplicity; -} -_Bool ms_contains(struct multiset *_set_, size_t value) -{ - _set_->flag = cmc_flags.OK; - _Bool result = ms_impl_get_entry(_set_, value) != ((void *)0); - if (_set_->callbacks && _set_->callbacks->read) - _set_->callbacks->read(); - return result; -} -_Bool ms_empty(struct multiset *_set_) -{ - return _set_->count == 0; -} -_Bool ms_full(struct multiset *_set_) -{ - return (double)_set_->capacity * _set_->load <= (double)_set_->count; -} -size_t ms_count(struct multiset *_set_) -{ - return _set_->count; -} -size_t ms_cardinality(struct multiset *_set_) -{ - return _set_->cardinality; -} -size_t ms_capacity(struct multiset *_set_) -{ - return _set_->capacity; -} -double ms_load(struct multiset *_set_) -{ - return _set_->load; -} -int ms_flag(struct multiset *_set_) -{ - return _set_->flag; -} -_Bool ms_resize(struct multiset *_set_, size_t capacity) -{ - _set_->flag = cmc_flags.OK; - if (_set_->capacity == capacity) - goto success; - if (_set_->capacity > capacity / _set_->load) - goto success; - if (capacity >= 0xffffffffffffffffULL * _set_->load) - { - _set_->flag = cmc_flags.ERROR; - return 0; - } - size_t theoretical_size = ms_impl_calculate_size(capacity); - if (theoretical_size < _set_->count / _set_->load) - { - _set_->flag = cmc_flags.INVALID; - return 0; - } - struct multiset *_new_set_ = ms_new_custom( - capacity, _set_->load, _set_->f_val, _set_->alloc, ((void *)0)); - if (!_new_set_) - { - _set_->flag = cmc_flags.ERROR; - return 0; - } - struct multiset_iter iter; - for (ms_iter_init(&iter, _set_); !ms_iter_end(&iter); ms_iter_next(&iter)) - { - ms_insert_many(_new_set_, ms_iter_value(&iter), - ms_iter_multiplicity(&iter)); - } - if (_set_->count != _new_set_->count) - { - ms_free(_new_set_); - _set_->flag = cmc_flags.ERROR; - return 0; - } - struct multiset_entry *tmp_b = _set_->buffer; - _set_->buffer = _new_set_->buffer; - _new_set_->buffer = tmp_b; - size_t tmp_c = _set_->capacity; - _set_->capacity = _new_set_->capacity; - _new_set_->capacity = tmp_c; - _new_set_->f_val = &(struct multiset_fval){ ((void *)0) }; - ms_free(_new_set_); -success: - if (_set_->callbacks && _set_->callbacks->resize) - _set_->callbacks->resize(); - return 1; -} -struct multiset *ms_copy_of(struct multiset *_set_) -{ - struct multiset *result = - ms_new_custom(_set_->capacity * _set_->load, _set_->load, _set_->f_val, - _set_->alloc, _set_->callbacks); - if (!result) - { - _set_->flag = cmc_flags.ERROR; - return ((void *)0); - } - if (_set_->f_val->cpy) - { - for (size_t i = 0; i < _set_->capacity; i++) - { - struct multiset_entry *scan = &(_set_->buffer[i]); - if (scan->state != CMC_ES_EMPTY) - { - struct multiset_entry *target = &(result->buffer[i]); - if (scan->state == CMC_ES_DELETED) - target->state = CMC_ES_DELETED; - else - { - target->state = scan->state; - target->dist = scan->dist; - target->multiplicity = scan->multiplicity; - target->value = _set_->f_val->cpy(scan->value); - } - } - } - } - else - memcpy(result->buffer, _set_->buffer, - sizeof(struct multiset_entry) * _set_->capacity); - result->count = _set_->count; - result->cardinality = _set_->cardinality; - _set_->flag = cmc_flags.OK; - return result; -} -_Bool ms_equals(struct multiset *_set1_, struct multiset *_set2_) -{ - _set1_->flag = cmc_flags.OK; - _set2_->flag = cmc_flags.OK; - if (_set1_->count != _set2_->count) - return 0; - if (_set1_->cardinality != _set2_->cardinality) - return 0; - if (_set1_->count == 0) - return 1; - struct multiset_iter iter; - ms_iter_init(&iter, _set1_); - for (ms_iter_to_start(&iter); !ms_iter_end(&iter); ms_iter_next(&iter)) - { - struct multiset_entry *entry = - ms_impl_get_entry(_set2_, ms_iter_value(&iter)); - if (!entry) - return 0; - if (entry->multiplicity != ms_iter_multiplicity(&iter)) - return 0; - } - return 1; -} -struct cmc_string ms_to_string(struct multiset *_set_) -{ - struct cmc_string str; - struct multiset *s_ = _set_; - int n = snprintf(str.s, cmc_string_len, cmc_string_fmt_multiset, "multiset", - "size_t", s_, s_->buffer, s_->capacity, s_->count, - s_->cardinality, s_->load, s_->flag, s_->f_val, s_->alloc, - s_->callbacks); - return n >= 0 ? str : (struct cmc_string){ 0 }; -} -_Bool ms_print(struct multiset *_set_, FILE *fptr) -{ - for (size_t i = 0; i < _set_->capacity; i++) - { - struct multiset_entry *entry = &(_set_->buffer[i]); - if (entry->state == CMC_ES_FILLED) - { - if (!_set_->f_val->str(fptr, entry->value)) - return 0; - } - } - return 1; -} -struct multiset *ms_union(struct multiset *_set1_, struct multiset *_set2_) -{ - struct multiset *_set_r_ = - ms_new_custom(_set1_->capacity, _set1_->load, _set1_->f_val, - _set1_->alloc, ((void *)0)); - if (!_set_r_) - return ((void *)0); - struct multiset_iter iter1, iter2; - ms_iter_init(&iter1, _set1_); - ms_iter_init(&iter2, _set2_); - for (ms_iter_to_start(&iter1); !ms_iter_end(&iter1); ms_iter_next(&iter1)) - { - size_t value = ms_iter_value(&iter1); - size_t m1 = ms_iter_multiplicity(&iter1); - size_t m2 = ms_impl_multiplicity_of(_set2_, value); - size_t max_ = m1 > m2 ? m1 : m2; - ms_update(_set_r_, value, max_); - } - for (ms_iter_to_start(&iter2); !ms_iter_end(&iter2); ms_iter_next(&iter2)) - { - size_t value = ms_iter_value(&iter2); - size_t m1 = ms_impl_multiplicity_of(_set1_, value); - size_t m2 = ms_iter_multiplicity(&iter2); - size_t max_ = m1 > m2 ? m1 : m2; - ms_update(_set_r_, value, max_); - } - _set_r_->callbacks = _set1_->callbacks; - return _set_r_; -} -struct multiset *ms_intersection(struct multiset *_set1_, - struct multiset *_set2_) -{ - struct multiset *_set_r_ = - ms_new_custom(_set1_->capacity, _set1_->load, _set1_->f_val, - _set1_->alloc, ((void *)0)); - if (!_set_r_) - return ((void *)0); - struct multiset *_set_A_ = _set1_->count < _set2_->count ? _set1_ : _set2_; - struct multiset *_set_B_ = _set_A_ == _set1_ ? _set2_ : _set1_; - struct multiset_iter iter; - ms_iter_init(&iter, _set_A_); - for (ms_iter_to_start(&iter); !ms_iter_end(&iter); ms_iter_next(&iter)) - { - size_t value = ms_iter_value(&iter); - size_t m1 = ms_iter_multiplicity(&iter); - size_t m2 = ms_impl_multiplicity_of(_set_B_, value); - size_t max_ = m1 < m2 ? m1 : m2; - ms_update(_set_r_, value, max_); - } - _set_r_->callbacks = _set1_->callbacks; - return _set_r_; -} -struct multiset *ms_difference(struct multiset *_set1_, struct multiset *_set2_) -{ - struct multiset *_set_r_ = - ms_new_custom(_set1_->capacity, _set1_->load, _set1_->f_val, - _set1_->alloc, ((void *)0)); - if (!_set_r_) - return ((void *)0); - struct multiset_iter iter; - ms_iter_init(&iter, _set1_); - for (ms_iter_to_start(&iter); !ms_iter_end(&iter); ms_iter_next(&iter)) - { - size_t value = ms_iter_value(&iter); - size_t m1 = ms_iter_multiplicity(&iter); - size_t m2 = ms_impl_multiplicity_of(_set2_, value); - if (m1 > m2) - ms_update(_set_r_, value, m1 - m2); - } - _set_r_->callbacks = _set1_->callbacks; - return _set_r_; -} -struct multiset *ms_summation(struct multiset *_set1_, struct multiset *_set2_) -{ - struct multiset *_set_r_ = - ms_new_custom(_set1_->capacity, _set1_->load, _set1_->f_val, - _set1_->alloc, ((void *)0)); - if (!_set_r_) - return ((void *)0); - struct multiset_iter iter1, iter2; - ms_iter_init(&iter1, _set1_); - ms_iter_init(&iter2, _set2_); - for (ms_iter_to_start(&iter1); !ms_iter_end(&iter1); ms_iter_next(&iter1)) - { - ms_insert_many(_set_r_, ms_iter_value(&iter1), - ms_iter_multiplicity(&iter1)); - } - for (ms_iter_to_start(&iter2); !ms_iter_end(&iter2); ms_iter_next(&iter2)) - { - ms_insert_many(_set_r_, ms_iter_value(&iter2), - ms_iter_multiplicity(&iter2)); - } - _set_r_->callbacks = _set1_->callbacks; - return _set_r_; -} -struct multiset *ms_symmetric_difference(struct multiset *_set1_, - struct multiset *_set2_) -{ - struct multiset *_set_r_ = - ms_new_custom(_set1_->capacity, _set1_->load, _set1_->f_val, - _set1_->alloc, ((void *)0)); - if (!_set_r_) - return ((void *)0); - struct multiset_iter iter1, iter2; - ms_iter_init(&iter1, _set1_); - ms_iter_init(&iter2, _set2_); - for (ms_iter_to_start(&iter1); !ms_iter_end(&iter1); ms_iter_next(&iter1)) - { - size_t value = ms_iter_value(&iter1); - size_t m1 = ms_iter_multiplicity(&iter1); - size_t m2 = ms_impl_multiplicity_of(_set2_, value); - if (m1 != m2) - { - if (m1 > m2) - ms_update(_set_r_, value, m1 - m2); - else - ms_update(_set_r_, value, m2 - m1); - } - } - for (ms_iter_to_start(&iter2); !ms_iter_end(&iter2); ms_iter_next(&iter2)) - { - size_t value = ms_iter_value(&iter2); - size_t m1 = ms_impl_multiplicity_of(_set1_, value); - size_t m2 = ms_iter_multiplicity(&iter2); - if (m1 != m2) - { - if (m1 > m2) - ms_update(_set_r_, value, m1 - m2); - else - ms_update(_set_r_, value, m2 - m1); - } - } - _set_r_->callbacks = _set1_->callbacks; - return _set_r_; -} -_Bool ms_is_subset(struct multiset *_set1_, struct multiset *_set2_) -{ - if (_set1_->count > _set2_->count) - return 0; - if (ms_empty(_set1_)) - return 1; - struct multiset_iter iter; - ms_iter_init(&iter, _set1_); - for (ms_iter_to_start(&iter); !ms_iter_end(&iter); ms_iter_next(&iter)) - { - size_t value = ms_iter_value(&iter); - size_t m1 = ms_iter_multiplicity(&iter); - size_t m2 = ms_impl_multiplicity_of(_set2_, value); - if (m1 > m2) - return 0; - } - return 1; -} -_Bool ms_is_superset(struct multiset *_set1_, struct multiset *_set2_) -{ - return ms_is_subset(_set2_, _set1_); -} -_Bool ms_is_proper_subset(struct multiset *_set1_, struct multiset *_set2_) -{ - if (_set1_->count >= _set2_->count) - return 0; - if (ms_empty(_set1_)) - { - if (!ms_empty(_set2_)) - return 1; - else - return 0; - } - struct multiset_iter iter; - ms_iter_init(&iter, _set1_); - for (ms_iter_to_start(&iter); !ms_iter_end(&iter); ms_iter_next(&iter)) - { - size_t value = ms_iter_value(&iter); - size_t m1 = ms_iter_multiplicity(&iter); - size_t m2 = ms_impl_multiplicity_of(_set2_, value); - if (m1 >= m2) - return 0; - } - return 1; -} -_Bool ms_is_proper_superset(struct multiset *_set1_, struct multiset *_set2_) -{ - return ms_is_proper_subset(_set2_, _set1_); -} -_Bool ms_is_disjointset(struct multiset *_set1_, struct multiset *_set2_) -{ - if (ms_empty(_set1_)) - return 1; - struct multiset_iter iter; - ms_iter_init(&iter, _set1_); - for (ms_iter_to_start(&iter); !ms_iter_end(&iter); ms_iter_next(&iter)) - { - size_t value = ms_iter_value(&iter); - if (ms_impl_get_entry(_set2_, value) != ((void *)0)) - return 0; - } - return 1; -} -struct multiset_iter *ms_iter_new(struct multiset *target) -{ - struct multiset_iter *iter = - target->alloc->malloc(sizeof(struct multiset_iter)); - if (!iter) - return ((void *)0); - ms_iter_init(iter, target); - return iter; -} -void ms_iter_free(struct multiset_iter *iter) -{ - iter->target->alloc->free(iter); -} -void ms_iter_init(struct multiset_iter *iter, struct multiset *target) -{ - memset(iter, 0, sizeof(struct multiset_iter)); - iter->target = target; - iter->start = 1; - iter->end = ms_empty(target); - if (!ms_empty(target)) - { - for (size_t i = 0; i < target->capacity; i++) - { - if (target->buffer[i].state == CMC_ES_FILLED) - { - iter->first = i; - break; - } - } - iter->cursor = iter->first; - for (size_t i = target->capacity; i > 0; i--) - { - if (target->buffer[i - 1].state == CMC_ES_FILLED) - { - iter->last = i - 1; - break; - } - } - } -} -_Bool ms_iter_start(struct multiset_iter *iter) -{ - return ms_empty(iter->target) || iter->start; -} -_Bool ms_iter_end(struct multiset_iter *iter) -{ - return ms_empty(iter->target) || iter->end; -} -void ms_iter_to_start(struct multiset_iter *iter) -{ - if (!ms_empty(iter->target)) - { - iter->cursor = iter->first; - iter->index = 0; - iter->start = 1; - iter->end = ms_empty(iter->target); - } -} -void ms_iter_to_end(struct multiset_iter *iter) -{ - if (!ms_empty(iter->target)) - { - iter->cursor = iter->last; - iter->index = iter->target->count - 1; - iter->start = ms_empty(iter->target); - iter->end = 1; - } -} -_Bool ms_iter_next(struct multiset_iter *iter) -{ - if (iter->end) - return 0; - if (iter->index + 1 == iter->target->count) - { - iter->end = 1; - return 0; - } - iter->start = ms_empty(iter->target); - struct multiset_entry *scan = &(iter->target->buffer[iter->cursor]); - iter->index++; - while (1) - { - iter->cursor++; - scan = &(iter->target->buffer[iter->cursor]); - if (scan->state == CMC_ES_FILLED) - break; - } - return 1; -} -_Bool ms_iter_prev(struct multiset_iter *iter) -{ - if (iter->start) - return 0; - if (iter->index == 0) - { - iter->start = 1; - return 0; - } - iter->end = ms_empty(iter->target); - struct multiset_entry *scan = &(iter->target->buffer[iter->cursor]); - iter->index--; - while (1) - { - iter->cursor--; - scan = &(iter->target->buffer[iter->cursor]); - if (scan->state == CMC_ES_FILLED) - break; - } - return 1; -} -_Bool ms_iter_advance(struct multiset_iter *iter, size_t steps) -{ - if (iter->end) - return 0; - if (iter->index + 1 == iter->target->count) - { - iter->end = 1; - return 0; - } - if (steps == 0 || iter->index + steps >= iter->target->count) - return 0; - for (size_t i = 0; i < steps; i++) - ms_iter_next(iter); - return 1; -} -_Bool ms_iter_rewind(struct multiset_iter *iter, size_t steps) -{ - if (iter->start) - return 0; - if (iter->index == 0) - { - iter->start = 1; - return 0; - } - if (steps == 0 || iter->index < steps) - return 0; - for (size_t i = 0; i < steps; i++) - ms_iter_prev(iter); - return 1; -} -_Bool ms_iter_go_to(struct multiset_iter *iter, size_t index) -{ - if (index >= iter->target->count) - return 0; - if (iter->index > index) - return ms_iter_rewind(iter, iter->index - index); - else if (iter->index < index) - return ms_iter_advance(iter, index - iter->index); - return 1; -} -size_t ms_iter_value(struct multiset_iter *iter) -{ - if (ms_empty(iter->target)) - return (size_t){ 0 }; - return iter->target->buffer[iter->cursor].value; -} -size_t ms_iter_multiplicity(struct multiset_iter *iter) -{ - if (ms_empty(iter->target)) - return 0; - return iter->target->buffer[iter->cursor].multiplicity; -} -size_t ms_iter_index(struct multiset_iter *iter) -{ - return iter->index; -} -static size_t ms_impl_multiplicity_of(struct multiset *_set_, size_t value) -{ - struct multiset_entry *entry = ms_impl_get_entry(_set_, value); - if (!entry) - return 0; - return entry->multiplicity; -} -static struct multiset_entry * -ms_impl_insert_and_return(struct multiset *_set_, size_t value, _Bool *new_node) -{ - *new_node = 0; - struct multiset_entry *entry = ms_impl_get_entry(_set_, value); - if (entry != ((void *)0)) - return entry; - *new_node = 1; - if (ms_full(_set_)) - { - if (!ms_resize(_set_, _set_->capacity + 1)) - return ((void *)0); - } - size_t hash = _set_->f_val->hash(value); - size_t original_pos = hash % _set_->capacity; - size_t pos = original_pos; - size_t curr_mul = 1; - struct multiset_entry *target = &(_set_->buffer[pos]); - if (target->state == CMC_ES_EMPTY || target->state == CMC_ES_DELETED) - { - target->value = value; - target->multiplicity = curr_mul; - target->dist = pos - original_pos; - target->state = CMC_ES_FILLED; - } - else - { - while (1) - { - pos++; - target = &(_set_->buffer[pos % _set_->capacity]); - if (target->state == CMC_ES_EMPTY || - target->state == CMC_ES_DELETED) - { - target->value = value; - target->multiplicity = curr_mul; - target->dist = pos - original_pos; - target->state = CMC_ES_FILLED; - break; - } - else if (target->dist < pos - original_pos) - { - size_t tmp = target->value; - size_t tmp_dist = target->dist; - size_t tmp_mul = target->multiplicity; - target->value = value; - target->dist = pos - original_pos; - target->multiplicity = curr_mul; - value = tmp; - original_pos = pos - tmp_dist; - curr_mul = tmp_mul; - } - } - } - _set_->count++; - return target; -} -static struct multiset_entry *ms_impl_get_entry(struct multiset *_set_, - size_t value) -{ - size_t hash = _set_->f_val->hash(value); - size_t pos = hash % _set_->capacity; - struct multiset_entry *target = &(_set_->buffer[pos]); - while (target->state == CMC_ES_FILLED || target->state == CMC_ES_DELETED) - { - if (_set_->f_val->cmp(target->value, value) == 0) - return target; - pos++; - target = &(_set_->buffer[pos % _set_->capacity]); - } - return ((void *)0); -} -static size_t ms_impl_calculate_size(size_t required) -{ - const size_t count = - sizeof(cmc_hashtable_primes) / sizeof(cmc_hashtable_primes[0]); - if (cmc_hashtable_primes[count - 1] < required) - return required; - size_t i = 0; - while (cmc_hashtable_primes[i] < required) - i++; - return cmc_hashtable_primes[i]; -} -static struct multiset_iter ms_impl_it_start(struct multiset *_set_) -{ - struct multiset_iter iter; - ms_iter_init(&iter, _set_); - return iter; -} -static struct multiset_iter ms_impl_it_end(struct multiset *_set_) -{ - struct multiset_iter iter; - ms_iter_init(&iter, _set_); - ms_iter_to_end(&iter); - return iter; -} diff --git a/tests/main/src/queue.c b/tests/main/src/queue.c index 8ed8089..f749065 100644 --- a/tests/main/src/queue.c +++ b/tests/main/src/queue.c @@ -1,3 +1,6 @@ +#ifndef CMC_TEST_SRC_QUEUE +#define CMC_TEST_SRC_QUEUE + #include "cmc/queue.h" struct queue @@ -494,3 +497,5 @@ size_t q_iter_index(struct queue_iter *iter) { return iter->index; } + +#endif /* CMC_TEST_SRC_QUEUE */ diff --git a/tests/main/src/sortedlist.c b/tests/main/src/sortedlist.c index 06ecf1c..efa0d92 100644 --- a/tests/main/src/sortedlist.c +++ b/tests/main/src/sortedlist.c @@ -1,3 +1,6 @@ +#ifndef CMC_TEST_SRC_SORTEDLIST +#define CMC_TEST_SRC_SORTEDLIST + #include "cmc/sortedlist.h" struct sortedlist @@ -584,3 +587,5 @@ void sl_impl_sort_insertion(size_t *array, int (*cmp)(size_t, size_t), array[j] = _tmp_; } } + +#endif /* CMC_TEST_SRC_SORTEDLIST */ diff --git a/tests/main/src/stack.c b/tests/main/src/stack.c index 63ec793..a0be8dd 100644 --- a/tests/main/src/stack.c +++ b/tests/main/src/stack.c @@ -1,3 +1,6 @@ +#ifndef CMC_TEST_SRC_STACK +#define CMC_TEST_SRC_STACK + #include "cmc/stack.h" struct stack @@ -428,3 +431,5 @@ size_t s_iter_index(struct stack_iter *iter) return 0; return iter->target->count - 1 - iter->cursor; } + +#endif /* CMC_TEST_SRC_STACK */ diff --git a/tests/main/src/treemap.c b/tests/main/src/treemap.c index 72c7ad2..f30a722 100644 --- a/tests/main/src/treemap.c +++ b/tests/main/src/treemap.c @@ -1,3 +1,6 @@ +#ifndef CMC_TEST_SRC_TREEMAP +#define CMC_TEST_SRC_TREEMAP + #include "cmc/treemap.h" struct treemap @@ -883,3 +886,5 @@ static void tm_impl_rebalance(struct treemap *_map_, struct treemap_node *node) scan = scan->parent; } } + +#endif /* CMC_TEST_SRC_TREEMAP */ diff --git a/tests/main/src/treeset.c b/tests/main/src/treeset.c index 3738567..517b40a 100644 --- a/tests/main/src/treeset.c +++ b/tests/main/src/treeset.c @@ -1,3 +1,6 @@ +#ifndef CMC_TEST_SRC_TREESET +#define CMC_TEST_SRC_TREESET + #include "cmc/treeset.h" struct treeset @@ -925,3 +928,5 @@ static void ts_impl_rebalance(struct treeset *_set_, struct treeset_node *node) scan = scan->parent; } } + +#endif /* CMC_TEST_SRC_TREESET */ diff --git a/tests/main/unt/bitset.c b/tests/main/unt/bitset.c index 3759a08..85c61b9 100644 --- a/tests/main/unt/bitset.c +++ b/tests/main/unt/bitset.c @@ -364,8 +364,7 @@ CMC_CREATE_UNIT(BitSet, true, { cmc_assert(bs_put_range(bs, 0, word_bits * 100 - 1, false)); for (size_t i = 0; i < bs->capacity; i++) - cmc_assert_equals(CMC_BITSET_WORD_TYPE, 0, - bs->buffer[i]); + cmc_assert_equals(CMC_BITSET_WORD_TYPE, 0, bs->buffer[i]); bs_free(bs); }); diff --git a/tests/main/unt/deque.c b/tests/main/unt/deque.c index acb9a56..c46374d 100644 --- a/tests/main/unt/deque.c +++ b/tests/main/unt/deque.c @@ -1732,10 +1732,12 @@ int main(void) { int result = Deque() + DequeIter(); - printf(" +---------------------------------------------------------------+"); + printf( + " +---------------------------------------------------------------+"); printf("\n"); printf(" | Deque Suit : %-48s |\n", result == 0 ? "PASSED" : "FAILED"); - printf(" +---------------------------------------------------------------+"); + printf( + " +---------------------------------------------------------------+"); printf("\n\n\n"); return result; diff --git a/tests/main/unt/hashbidimap.c b/tests/main/unt/hashbidimap.c index edcc476..d9342a1 100644 --- a/tests/main/unt/hashbidimap.c +++ b/tests/main/unt/hashbidimap.c @@ -825,19 +825,23 @@ CMC_CREATE_UNIT(HashBidiMap, true, { }); }); -CMC_CREATE_UNIT(HashBidiMapIter, true, { +CMC_CREATE_UNIT(HashBidiMapIter, true, + { -}); + }); #ifdef CMC_TEST_MAIN int main(void) { int result = HashBidiMap() + HashBidiMapIter(); - printf(" +---------------------------------------------------------------+"); + printf( + " +---------------------------------------------------------------+"); printf("\n"); - printf(" | HashBidiMap Suit : %-42s |\n", result == 0 ? "PASSED" : "FAILED"); - printf(" +---------------------------------------------------------------+"); + printf(" | HashBidiMap Suit : %-42s |\n", + result == 0 ? "PASSED" : "FAILED"); + printf( + " +---------------------------------------------------------------+"); printf("\n\n\n"); return result; diff --git a/tests/main/unt/hashmap.c b/tests/main/unt/hashmap.c index 5ac006b..f43e576 100644 --- a/tests/main/unt/hashmap.c +++ b/tests/main/unt/hashmap.c @@ -1344,10 +1344,12 @@ int main(void) { int result = HashMap() + HashMapIter(); - printf(" +---------------------------------------------------------------+"); + printf( + " +---------------------------------------------------------------+"); printf("\n"); printf(" | HashMap Suit : %-46s |\n", result == 0 ? "PASSED" : "FAILED"); - printf(" +---------------------------------------------------------------+"); + printf( + " +---------------------------------------------------------------+"); printf("\n\n\n"); return result; diff --git a/tests/main/unt/hashmultimap.c b/tests/main/unt/hashmultimap.c index 443b5c1..dfacb6a 100644 --- a/tests/main/unt/hashmultimap.c +++ b/tests/main/unt/hashmultimap.c @@ -944,10 +944,13 @@ int main(void) { int result = HashMultiMap() + HashMultiMapIter(); - printf(" +---------------------------------------------------------------+"); + printf( + " +---------------------------------------------------------------+"); printf("\n"); - printf(" | HashMultiMap Suit : %-41s |\n", result == 0 ? "PASSED" : "FAILED"); - printf(" +---------------------------------------------------------------+"); + printf(" | HashMultiMap Suit : %-41s |\n", + result == 0 ? "PASSED" : "FAILED"); + printf( + " +---------------------------------------------------------------+"); printf("\n\n\n"); return result; diff --git a/tests/main/unt/hashmultiset.c b/tests/main/unt/hashmultiset.c index 0bc59fc..2c2bf74 100644 --- a/tests/main/unt/hashmultiset.c +++ b/tests/main/unt/hashmultiset.c @@ -864,10 +864,13 @@ int main(void) { int result = HashMultiSet() + HashMultiSetIter(); - printf(" +---------------------------------------------------------------+"); + printf( + " +---------------------------------------------------------------+"); printf("\n"); - printf(" | HashMultiSet Suit : %-41s |\n", result == 0 ? "PASSED" : "FAILED"); - printf(" +---------------------------------------------------------------+"); + printf(" | HashMultiSet Suit : %-41s |\n", + result == 0 ? "PASSED" : "FAILED"); + printf( + " +---------------------------------------------------------------+"); printf("\n\n\n"); return result; diff --git a/tests/main/unt/hashset.c b/tests/main/unt/hashset.c index 2e3560e..22bdd0e 100644 --- a/tests/main/unt/hashset.c +++ b/tests/main/unt/hashset.c @@ -1042,10 +1042,12 @@ int main(void) { int result = HashSet() + HashSetIter(); - printf(" +---------------------------------------------------------------+"); + printf( + " +---------------------------------------------------------------+"); printf("\n"); printf(" | HashSet Suit : %-46s |\n", result == 0 ? "PASSED" : "FAILED"); - printf(" +---------------------------------------------------------------+"); + printf( + " +---------------------------------------------------------------+"); printf("\n\n\n"); return result; diff --git a/tests/main/unt/intervalheap.c b/tests/main/unt/intervalheap.c index 0eed15a..88dea15 100644 --- a/tests/main/unt/intervalheap.c +++ b/tests/main/unt/intervalheap.c @@ -1044,10 +1044,13 @@ int main(void) { int result = IntervalHeap() + IntervalHeapIter(); - printf(" +---------------------------------------------------------------+"); + printf( + " +---------------------------------------------------------------+"); printf("\n"); - printf(" | IntervalHeap Suit : %-41s |\n", result == 0 ? "PASSED" : "FAILED"); - printf(" +---------------------------------------------------------------+"); + printf(" | IntervalHeap Suit : %-41s |\n", + result == 0 ? "PASSED" : "FAILED"); + printf( + " +---------------------------------------------------------------+"); printf("\n\n\n"); return result; diff --git a/tests/main/unt/linkedlist.c b/tests/main/unt/linkedlist.c index db542b2..7e5113a 100644 --- a/tests/main/unt/linkedlist.c +++ b/tests/main/unt/linkedlist.c @@ -804,10 +804,12 @@ int main(void) { int result = LinkedList() + LinkedListIter(); - printf(" +---------------------------------------------------------------+"); + printf( + " +---------------------------------------------------------------+"); printf("\n"); printf(" | LinkedList Suit : %-43s |\n", result == 0 ? "PASSED" : "FAILED"); - printf(" +---------------------------------------------------------------+"); + printf( + " +---------------------------------------------------------------+"); printf("\n\n\n"); return result; diff --git a/tests/main/unt/list.c b/tests/main/unt/list.c index 1a96c24..c98d0d2 100644 --- a/tests/main/unt/list.c +++ b/tests/main/unt/list.c @@ -1070,10 +1070,12 @@ int main(void) { int result = List() + ListIter(); - printf(" +---------------------------------------------------------------+"); + printf( + " +---------------------------------------------------------------+"); printf("\n"); printf(" | List Suit : %-49s |\n", result == 0 ? "PASSED" : "FAILED"); - printf(" +---------------------------------------------------------------+"); + printf( + " +---------------------------------------------------------------+"); printf("\n\n\n"); return result; diff --git a/tests/main/unt/queue.c b/tests/main/unt/queue.c index 3d1194d..f988730 100644 --- a/tests/main/unt/queue.c +++ b/tests/main/unt/queue.c @@ -688,7 +688,7 @@ CMC_CREATE_UNIT(QueueIter, true, { cmc_assert(!q_iter_to_end(&it)); for (size_t i = 1; i <= 100; i++) - q_enqueue(q, i); + q_enqueue(q, i); it = q_iter_start(q); @@ -960,10 +960,12 @@ int main(void) { int result = Queue() + QueueIter(); - printf(" +---------------------------------------------------------------+"); + printf( + " +---------------------------------------------------------------+"); printf("\n"); printf(" | Queue Suit : %-48s |\n", result == 0 ? "PASSED" : "FAILED"); - printf(" +---------------------------------------------------------------+"); + printf( + " +---------------------------------------------------------------+"); printf("\n\n\n"); return result; diff --git a/tests/main/unt/sortedlist.c b/tests/main/unt/sortedlist.c index 0ab4bff..68e23dc 100644 --- a/tests/main/unt/sortedlist.c +++ b/tests/main/unt/sortedlist.c @@ -705,10 +705,12 @@ int main(void) { int result = SortedList() + SortedListIter(); - printf(" +---------------------------------------------------------------+"); + printf( + " +---------------------------------------------------------------+"); printf("\n"); printf(" | SortedList Suit : %-43s |\n", result == 0 ? "PASSED" : "FAILED"); - printf(" +---------------------------------------------------------------+"); + printf( + " +---------------------------------------------------------------+"); printf("\n\n\n"); return result; diff --git a/tests/main/unt/stack.c b/tests/main/unt/stack.c index 0da4ecb..8537d58 100644 --- a/tests/main/unt/stack.c +++ b/tests/main/unt/stack.c @@ -838,10 +838,12 @@ int main(void) { int result = Stack() + StackIter(); - printf(" +---------------------------------------------------------------+"); + printf( + " +---------------------------------------------------------------+"); printf("\n"); printf(" | Stack Suit : %-48s |\n", result == 0 ? "PASSED" : "FAILED"); - printf(" +---------------------------------------------------------------+"); + printf( + " +---------------------------------------------------------------+"); printf("\n\n\n"); return result; diff --git a/tests/main/unt/treemap.c b/tests/main/unt/treemap.c index c3e2c5c..909224b 100644 --- a/tests/main/unt/treemap.c +++ b/tests/main/unt/treemap.c @@ -659,10 +659,12 @@ int main(void) { int result = TreeMap() + TreeMapIter(); - printf(" +---------------------------------------------------------------+"); + printf( + " +---------------------------------------------------------------+"); printf("\n"); printf(" | TreeMap Suit : %-46s |\n", result == 0 ? "PASSED" : "FAILED"); - printf(" +---------------------------------------------------------------+"); + printf( + " +---------------------------------------------------------------+"); printf("\n\n\n"); return result; diff --git a/tests/main/unt/treeset.c b/tests/main/unt/treeset.c index 8c35990..46bc04e 100644 --- a/tests/main/unt/treeset.c +++ b/tests/main/unt/treeset.c @@ -574,10 +574,12 @@ int main(void) { int result = TreeSet() + TreeSetIter(); - printf(" +---------------------------------------------------------------+"); + printf( + " +---------------------------------------------------------------+"); printf("\n"); printf(" | TreeSet Suit : %-46s |\n", result == 0 ? "PASSED" : "FAILED"); - printf(" +---------------------------------------------------------------+"); + printf( + " +---------------------------------------------------------------+"); printf("\n\n\n"); return result;