Tests reworked - CI might not work

This commit is contained in:
Leonardo Vencovsky committed 2020-06-11 21:23:42 -03:00
1 parent f8607e8cdc
commit 4bebb90cb6
65 files changed
+2071 -1952

No files matched your search

-22
View File
@@ -1,22 +0,0 @@
CC = gcc
CFLAGS = -std=c11 -Wall -Wextra
CFLAGS += -Wno-unused -Wno-missing-braces
main: FORCE
$(CC) foreach.c -o foreach.exe $(CFLAGS)
./foreach.exe
$(CC) iterators.c -o iterators.exe $(CFLAGS)
./iterators.exe
$(CC) contains.c -o contains.exe $(CFLAGS)
./contains.exe
$(CC) types.c -o types.exe $(CFLAGS)
./types.exe
make -C ./sep
dev: main
rm *.exe ./sep/*.o ./sep/*.exe
windev: main
del *.exe .\\sep\\*.o .\\sep\\*.exe
FORCE:
-9
View File
@@ -1,9 +0,0 @@
# Tests
* `codecov` - A stalled version for codecov;
* `main` - Unit tests for the main C Macro Collections library;
* `sep/main.c`, `sep/sep.c` and `sep/sep.h` - Tests separate header and source compilation;
* `contains.c` - Tests the `contains` function for all collections;
* `foreach.c` - Tests the ForEach macros for all collections;
* `iterators.c` - Tests all collection's iterators;
* `types.c` - Tests if all containers accept all possible C data types (struct, union, enum, pointers, function pointers)
+51
View File
@@ -0,0 +1,51 @@
#ifndef CMC_CMC_BITSET_TEST_H
#define CMC_CMC_BITSET_TEST_H
#include "macro_collections.h"
struct bitset
{
cmc_bitset_word *buffer;
size_t capacity;
int flag;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct bitset_iter
{
struct bitset *target;
size_t cursor;
_Bool start;
_Bool end;
};
struct bitset *bs_new(size_t n_bits);
struct bitset *bs_new_custom(size_t n_bits, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
struct bitset bs_init(size_t n_bits);
struct bitset bs_init_custom(size_t n_bits, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
void bs_free(struct bitset *_bitset_);
void bs_release(struct bitset _bitset_);
void bs_customize(struct bitset *_bitset_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool bs_set(struct bitset *_bitset_, size_t bit_index);
_Bool bs_set_range(struct bitset *_bitset_, size_t from, size_t to);
_Bool bs_clear(struct bitset *_bitset_, size_t bit_index);
_Bool bs_clear_range(struct bitset *_bitset_, size_t from, size_t to);
_Bool bs_flip(struct bitset *_bitset_, size_t bit_index);
_Bool bs_flip_range(struct bitset *_bitset_, size_t from, size_t to);
_Bool bs_put(struct bitset *_bitset_, size_t bit_index, _Bool state);
_Bool bs_put_range(struct bitset *_bitset_, size_t from, size_t to, _Bool state);
_Bool bs_set_all(struct bitset *_bitset_);
_Bool bs_clear_all(struct bitset *_bitset_);
_Bool bs_flip_all(struct bitset *_bitset_);
_Bool bs_get(struct bitset *_bitset_, size_t bit_index);
_Bool bs_resize(struct bitset *_bitset_, size_t n_bits);
static inline size_t bs_bit_to_index(size_t idx)
{
static const size_t shift =
((sizeof(cmc_bitset_word) * 8) >> 6) > 0
? 6
: ((sizeof(cmc_bitset_word) * 8) >> 5) > 0 ? 5 : ((sizeof(cmc_bitset_word) * 8) >> 4) > 0 ? 4 : 3;
return idx >> shift;
}
#endif /* CMC_CMC_BITSET_TEST_H */
+78
View File
@@ -0,0 +1,78 @@
#ifndef CMC_CMC_DEQUE_TEST_H
#define CMC_CMC_DEQUE_TEST_H
#include "macro_collections.h"
struct deque
{
size_t *buffer;
size_t capacity;
size_t count;
size_t front;
size_t back;
int flag;
struct deque_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct deque_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 deque *d_new(size_t capacity, struct deque_fval *f_val);
struct deque *d_new_custom(size_t capacity, struct deque_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void d_clear(struct deque *_deque_);
void d_free(struct deque *_deque_);
void d_customize(struct deque *_deque_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool d_push_front(struct deque *_deque_, size_t value);
_Bool d_push_back(struct deque *_deque_, size_t value);
_Bool d_pop_front(struct deque *_deque_);
_Bool d_pop_back(struct deque *_deque_);
size_t d_front(struct deque *_deque_);
size_t d_back(struct deque *_deque_);
_Bool d_contains(struct deque *_deque_, size_t value);
_Bool d_empty(struct deque *_deque_);
_Bool d_full(struct deque *_deque_);
size_t d_count(struct deque *_deque_);
size_t d_capacity(struct deque *_deque_);
int d_flag(struct deque *_deque_);
_Bool d_resize(struct deque *_deque_, size_t capacity);
struct deque *d_copy_of(struct deque *_deque_);
_Bool d_equals(struct deque *_deque1_, struct deque *_deque2_);
struct deque d_init(size_t capacity, struct deque_fval *f_val);
struct deque d_init_custom(size_t capacity, struct deque_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void d_release(struct deque _deque_);
struct deque_iter
{
struct deque *target;
size_t cursor;
size_t index;
_Bool start;
_Bool end;
};
struct deque_iter d_iter_start(struct deque *target);
struct deque_iter d_iter_end(struct deque *target);
_Bool d_iter_at_start(struct deque_iter *iter);
_Bool d_iter_at_end(struct deque_iter *iter);
_Bool d_iter_to_start(struct deque_iter *iter);
_Bool d_iter_to_end(struct deque_iter *iter);
_Bool d_iter_next(struct deque_iter *iter);
_Bool d_iter_prev(struct deque_iter *iter);
_Bool d_iter_advance(struct deque_iter *iter, size_t steps);
_Bool d_iter_rewind(struct deque_iter *iter, size_t steps);
_Bool d_iter_go_to(struct deque_iter *iter, size_t index);
size_t d_iter_value(struct deque_iter *iter);
size_t *d_iter_rvalue(struct deque_iter *iter);
size_t d_iter_index(struct deque_iter *iter);
_Bool d_to_string(struct deque *_deque_, FILE *fptr);
_Bool d_print(struct deque *_deque_, FILE *fptr, const char *start, const char *separator, const char *end);
#endif /* CMC_CMC_DEQUE_TEST_H */
+101
View File
@@ -0,0 +1,101 @@
#ifndef CMC_CMC_HASHBIDIMAP_TEST_H
#define CMC_CMC_HASHBIDIMAP_TEST_H
#include "macro_collections.h"
struct hashbidimap
{
struct hashbidimap_entry *(*buffer)[2];
size_t capacity;
size_t count;
double load;
int flag;
struct hashbidimap_fkey *f_key;
struct hashbidimap_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
struct hashbidimap_iter (*it_start)(struct hashbidimap *);
struct hashbidimap_iter (*it_end)(struct hashbidimap *);
};
struct hashbidimap_entry
{
size_t key;
size_t value;
size_t dist[2];
struct hashbidimap_entry **ref[2];
};
struct hashbidimap_fkey
{
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 hashbidimap_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 hashbidimap_iter
{
struct hashbidimap *target;
size_t cursor;
size_t index;
size_t first;
size_t last;
_Bool start;
_Bool end;
};
struct hashbidimap *hbm_new(size_t capacity, double load, struct hashbidimap_fkey *f_key,
struct hashbidimap_fval *f_val);
struct hashbidimap *hbm_new_custom(size_t capacity, double load, struct hashbidimap_fkey *f_key,
struct hashbidimap_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void hbm_clear(struct hashbidimap *_map_);
void hbm_free(struct hashbidimap *_map_);
void hbm_customize(struct hashbidimap *_map_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool hbm_insert(struct hashbidimap *_map_, size_t key, size_t value);
_Bool hbm_update_key(struct hashbidimap *_map_, size_t val, size_t new_key);
_Bool hbm_update_val(struct hashbidimap *_map_, size_t key, size_t new_val);
_Bool hbm_remove_by_key(struct hashbidimap *_map_, size_t key, size_t *out_key, size_t *out_val);
_Bool hbm_remove_by_val(struct hashbidimap *_map_, size_t val, size_t *out_key, size_t *out_val);
size_t hbm_get_key(struct hashbidimap *_map_, size_t val);
size_t hbm_get_val(struct hashbidimap *_map_, size_t key);
_Bool hbm_contains_key(struct hashbidimap *_map_, size_t key);
_Bool hbm_contains_val(struct hashbidimap *_map_, size_t val);
_Bool hbm_empty(struct hashbidimap *_map_);
_Bool hbm_full(struct hashbidimap *_map_);
size_t hbm_count(struct hashbidimap *_map_);
size_t hbm_capacity(struct hashbidimap *_map_);
double hbm_load(struct hashbidimap *_map_);
int hbm_flag(struct hashbidimap *_map_);
_Bool hbm_resize(struct hashbidimap *_map_, size_t capacity);
struct hashbidimap *hbm_copy_of(struct hashbidimap *_map_);
_Bool hbm_equals(struct hashbidimap *_map1_, struct hashbidimap *_map2_);
struct hashbidimap_iter *hbm_iter_new(struct hashbidimap *target);
void hbm_iter_free(struct hashbidimap_iter *iter);
void hbm_iter_init(struct hashbidimap_iter *iter, struct hashbidimap *target);
_Bool hbm_iter_start(struct hashbidimap_iter *iter);
_Bool hbm_iter_end(struct hashbidimap_iter *iter);
void hbm_iter_to_start(struct hashbidimap_iter *iter);
void hbm_iter_to_end(struct hashbidimap_iter *iter);
_Bool hbm_iter_next(struct hashbidimap_iter *iter);
_Bool hbm_iter_prev(struct hashbidimap_iter *iter);
_Bool hbm_iter_advance(struct hashbidimap_iter *iter, size_t steps);
_Bool hbm_iter_rewind(struct hashbidimap_iter *iter, size_t steps);
_Bool hbm_iter_go_to(struct hashbidimap_iter *iter, size_t index);
size_t hbm_iter_key(struct hashbidimap_iter *iter);
size_t hbm_iter_value(struct hashbidimap_iter *iter);
size_t hbm_iter_index(struct hashbidimap_iter *iter);
_Bool hbm_to_string(struct hashbidimap *_map_, FILE *fptr);
_Bool hbm_print(struct hashbidimap *_map_, FILE *fptr, const char *start, const char *separator, const char *end,
const char *key_val_sep);
#endif /* CMC_CMC_HASHBIDIMAP_TEST_H */
+100
View File
@@ -0,0 +1,100 @@
#ifndef CMC_CMC_HASHMAP_TEST_H
#define CMC_CMC_HASHMAP_TEST_H
#include "macro_collections.h"
struct hashmap
{
struct hashmap_entry *buffer;
size_t capacity;
size_t count;
double load;
int flag;
struct hashmap_fkey *f_key;
struct hashmap_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct hashmap_entry
{
size_t key;
size_t value;
size_t dist;
enum cmc_entry_state state;
};
struct hashmap_fkey
{
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 hashmap_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 hashmap *hm_new(size_t capacity, double load, struct hashmap_fkey *f_key, struct hashmap_fval *f_val);
struct hashmap *hm_new_custom(size_t capacity, double load, struct hashmap_fkey *f_key, struct hashmap_fval *f_val,
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
void hm_clear(struct hashmap *_map_);
void hm_free(struct hashmap *_map_);
void hm_customize(struct hashmap *_map_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool hm_insert(struct hashmap *_map_, size_t key, size_t value);
_Bool hm_update(struct hashmap *_map_, size_t key, size_t new_value, size_t *old_value);
_Bool hm_remove(struct hashmap *_map_, size_t key, size_t *out_value);
_Bool hm_max(struct hashmap *_map_, size_t *key, size_t *value);
_Bool hm_min(struct hashmap *_map_, size_t *key, size_t *value);
size_t hm_get(struct hashmap *_map_, size_t key);
size_t *hm_get_ref(struct hashmap *_map_, size_t key);
_Bool hm_contains(struct hashmap *_map_, size_t key);
_Bool hm_empty(struct hashmap *_map_);
_Bool hm_full(struct hashmap *_map_);
size_t hm_count(struct hashmap *_map_);
size_t hm_capacity(struct hashmap *_map_);
double hm_load(struct hashmap *_map_);
int hm_flag(struct hashmap *_map_);
_Bool hm_resize(struct hashmap *_map_, size_t capacity);
struct hashmap *hm_copy_of(struct hashmap *_map_);
_Bool hm_equals(struct hashmap *_map1_, struct hashmap *_map2_);
struct hashmap hm_init(size_t capacity, double load, struct hashmap_fkey *f_key, struct hashmap_fval *f_val);
struct hashmap hm_init_custom(size_t capacity, double load, struct hashmap_fkey *f_key, struct hashmap_fval *f_val,
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
void hm_release(struct hashmap _map_);
struct hashmap_iter
{
struct hashmap *target;
size_t cursor;
size_t index;
size_t first;
size_t last;
_Bool start;
_Bool end;
};
struct hashmap_iter hm_iter_start(struct hashmap *target);
struct hashmap_iter hm_iter_end(struct hashmap *target);
_Bool hm_iter_at_start(struct hashmap_iter *iter);
_Bool hm_iter_at_end(struct hashmap_iter *iter);
_Bool hm_iter_to_start(struct hashmap_iter *iter);
_Bool hm_iter_to_end(struct hashmap_iter *iter);
_Bool hm_iter_next(struct hashmap_iter *iter);
_Bool hm_iter_prev(struct hashmap_iter *iter);
_Bool hm_iter_advance(struct hashmap_iter *iter, size_t steps);
_Bool hm_iter_rewind(struct hashmap_iter *iter, size_t steps);
_Bool hm_iter_go_to(struct hashmap_iter *iter, size_t index);
size_t hm_iter_key(struct hashmap_iter *iter);
size_t hm_iter_value(struct hashmap_iter *iter);
size_t *hm_iter_rvalue(struct hashmap_iter *iter);
size_t hm_iter_index(struct hashmap_iter *iter);
_Bool hm_to_string(struct hashmap *_map_, FILE *fptr);
_Bool hm_print(struct hashmap *_map_, FILE *fptr, const char *start, const char *separator, const char *end,
const char *key_val_sep);
#endif /* CMC_CMC_HASHMAP_TEST_H */
+102
View File
@@ -0,0 +1,102 @@
#ifndef CMC_CMC_HASHMULTIMAP_TEST_H
#define CMC_CMC_HASHMULTIMAP_TEST_H
#include "macro_collections.h"
struct hashmultimap
{
struct hashmultimap_entry *(*buffer)[2];
size_t capacity;
size_t count;
double load;
int flag;
struct hashmultimap_fkey *f_key;
struct hashmultimap_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct hashmultimap_entry
{
size_t key;
size_t value;
struct hashmultimap_entry *next;
struct hashmultimap_entry *prev;
};
struct hashmultimap_fkey
{
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 hashmultimap_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 hashmultimap *hmm_new(size_t capacity, double load, struct hashmultimap_fkey *f_key,
struct hashmultimap_fval *f_val);
struct hashmultimap *hmm_new_custom(size_t capacity, double load, struct hashmultimap_fkey *f_key,
struct hashmultimap_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void hmm_clear(struct hashmultimap *_map_);
void hmm_free(struct hashmultimap *_map_);
void hmm_customize(struct hashmultimap *_map_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool hmm_insert(struct hashmultimap *_map_, size_t key, size_t value);
_Bool hmm_update(struct hashmultimap *_map_, size_t key, size_t new_value, size_t *old_value);
size_t hmm_update_all(struct hashmultimap *_map_, size_t key, size_t new_value, size_t **old_values);
_Bool hmm_remove(struct hashmultimap *_map_, size_t key, size_t *out_value);
size_t hmm_remove_all(struct hashmultimap *_map_, size_t key, size_t **out_values);
_Bool hmm_max(struct hashmultimap *_map_, size_t *key, size_t *value);
_Bool hmm_min(struct hashmultimap *_map_, size_t *key, size_t *value);
size_t hmm_get(struct hashmultimap *_map_, size_t key);
size_t *hmm_get_ref(struct hashmultimap *_map_, size_t key);
_Bool hmm_contains(struct hashmultimap *_map_, size_t key);
_Bool hmm_empty(struct hashmultimap *_map_);
_Bool hmm_full(struct hashmultimap *_map_);
size_t hmm_count(struct hashmultimap *_map_);
size_t hmm_key_count(struct hashmultimap *_map_, size_t key);
size_t hmm_capacity(struct hashmultimap *_map_);
double hmm_load(struct hashmultimap *_map_);
int hmm_flag(struct hashmultimap *_map_);
_Bool hmm_resize(struct hashmultimap *_map_, size_t capacity);
struct hashmultimap *hmm_copy_of(struct hashmultimap *_map_);
_Bool hmm_equals(struct hashmultimap *_map1_, struct hashmultimap *_map2_);
struct hashmultimap_iter
{
struct hashmultimap *target;
struct hashmultimap_entry *curr_entry;
size_t cursor;
size_t index;
size_t first;
size_t last;
_Bool start;
_Bool end;
};
struct hashmultimap_iter hmm_iter_start(struct hashmultimap *target);
struct hashmultimap_iter hmm_iter_end(struct hashmultimap *target);
_Bool hmm_iter_at_start(struct hashmultimap_iter *iter);
_Bool hmm_iter_at_end(struct hashmultimap_iter *iter);
_Bool hmm_iter_to_start(struct hashmultimap_iter *iter);
_Bool hmm_iter_to_end(struct hashmultimap_iter *iter);
_Bool hmm_iter_next(struct hashmultimap_iter *iter);
_Bool hmm_iter_prev(struct hashmultimap_iter *iter);
_Bool hmm_iter_advance(struct hashmultimap_iter *iter, size_t steps);
_Bool hmm_iter_rewind(struct hashmultimap_iter *iter, size_t steps);
_Bool hmm_iter_go_to(struct hashmultimap_iter *iter, size_t index);
size_t hmm_iter_key(struct hashmultimap_iter *iter);
size_t hmm_iter_value(struct hashmultimap_iter *iter);
size_t *hmm_iter_rvalue(struct hashmultimap_iter *iter);
size_t hmm_iter_index(struct hashmultimap_iter *iter);
_Bool hmm_to_string(struct hashmultimap *_map_, FILE *fptr);
_Bool hmm_print(struct hashmultimap *_map_, FILE *fptr, const char *start, const char *separator, const char *end,
const char *key_val_sep);
#endif /* CMC_CMC_HASHMULTIMAP_TEST_H */
+98
View File
@@ -0,0 +1,98 @@
#ifndef CMC_CMC_HASHMULTISET_TEST_H
#define CMC_CMC_HASHMULTISET_TEST_H
#include "macro_collections.h"
struct hashmultiset
{
struct hashmultiset_entry *buffer;
size_t capacity;
size_t count;
size_t cardinality;
double load;
int flag;
struct hashmultiset_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct hashmultiset_entry
{
size_t value;
size_t multiplicity;
size_t dist;
enum cmc_entry_state state;
};
struct hashmultiset_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 hashmultiset *hms_new(size_t capacity, double load, struct hashmultiset_fval *f_val);
struct hashmultiset *hms_new_custom(size_t capacity, double load, struct hashmultiset_fval *f_val,
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
void hms_clear(struct hashmultiset *_set_);
void hms_free(struct hashmultiset *_set_);
void hms_customize(struct hashmultiset *_set_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool hms_insert(struct hashmultiset *_set_, size_t value);
_Bool hms_insert_many(struct hashmultiset *_set_, size_t value, size_t count);
_Bool hms_update(struct hashmultiset *_set_, size_t value, size_t multiplicity);
_Bool hms_remove(struct hashmultiset *_set_, size_t value);
size_t hms_remove_all(struct hashmultiset *_set_, size_t value);
_Bool hms_max(struct hashmultiset *_set_, size_t *value);
_Bool hms_min(struct hashmultiset *_set_, size_t *value);
size_t hms_multiplicity_of(struct hashmultiset *_set_, size_t value);
_Bool hms_contains(struct hashmultiset *_set_, size_t value);
_Bool hms_empty(struct hashmultiset *_set_);
_Bool hms_full(struct hashmultiset *_set_);
size_t hms_count(struct hashmultiset *_set_);
size_t hms_cardinality(struct hashmultiset *_set_);
size_t hms_capacity(struct hashmultiset *_set_);
double hms_load(struct hashmultiset *_set_);
int hms_flag(struct hashmultiset *_set_);
_Bool hms_resize(struct hashmultiset *_set_, size_t capacity);
struct hashmultiset *hms_copy_of(struct hashmultiset *_set_);
_Bool hms_equals(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
struct hashmultiset_iter
{
struct hashmultiset *target;
size_t cursor;
size_t index;
size_t first;
size_t last;
_Bool start;
_Bool end;
};
struct hashmultiset_iter hms_iter_start(struct hashmultiset *target);
struct hashmultiset_iter hms_iter_end(struct hashmultiset *target);
_Bool hms_iter_at_start(struct hashmultiset_iter *iter);
_Bool hms_iter_at_end(struct hashmultiset_iter *iter);
_Bool hms_iter_to_start(struct hashmultiset_iter *iter);
_Bool hms_iter_to_end(struct hashmultiset_iter *iter);
_Bool hms_iter_next(struct hashmultiset_iter *iter);
_Bool hms_iter_prev(struct hashmultiset_iter *iter);
_Bool hms_iter_advance(struct hashmultiset_iter *iter, size_t steps);
_Bool hms_iter_rewind(struct hashmultiset_iter *iter, size_t steps);
_Bool hms_iter_go_to(struct hashmultiset_iter *iter, size_t index);
size_t hms_iter_value(struct hashmultiset_iter *iter);
size_t hms_iter_multiplicity(struct hashmultiset_iter *iter);
size_t hms_iter_index(struct hashmultiset_iter *iter);
struct hashmultiset *hms_union(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
struct hashmultiset *hms_intersection(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
struct hashmultiset *hms_difference(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
struct hashmultiset *hms_summation(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
struct hashmultiset *hms_symmetric_difference(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
_Bool hms_is_subset(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
_Bool hms_is_superset(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
_Bool hms_is_proper_subset(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
_Bool hms_is_proper_superset(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
_Bool hms_is_disjointset(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
_Bool hms_to_string(struct hashmultiset *_set_, FILE *fptr);
_Bool hms_print(struct hashmultiset *_set_, FILE *fptr, const char *start, const char *separator, const char *end,
const char *key_val_sep);
#endif /* CMC_CMC_HASHMULTISET_TEST_H */
+88
View File
@@ -0,0 +1,88 @@
#ifndef CMC_CMC_HASHSET_TEST_H
#define CMC_CMC_HASHSET_TEST_H
#include "macro_collections.h"
struct hashset
{
struct hashset_entry *buffer;
size_t capacity;
size_t count;
double load;
int flag;
struct hashset_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct hashset_entry
{
size_t value;
size_t dist;
enum cmc_entry_state state;
};
struct hashset_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 hashset *hs_new(size_t capacity, double load, struct hashset_fval *f_val);
struct hashset *hs_new_custom(size_t capacity, double load, struct hashset_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void hs_clear(struct hashset *_set_);
void hs_free(struct hashset *_set_);
void hs_customize(struct hashset *_set_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool hs_insert(struct hashset *_set_, size_t value);
_Bool hs_remove(struct hashset *_set_, size_t value);
_Bool hs_max(struct hashset *_set_, size_t *value);
_Bool hs_min(struct hashset *_set_, size_t *value);
_Bool hs_contains(struct hashset *_set_, size_t value);
_Bool hs_empty(struct hashset *_set_);
_Bool hs_full(struct hashset *_set_);
size_t hs_count(struct hashset *_set_);
size_t hs_capacity(struct hashset *_set_);
double hs_load(struct hashset *_set_);
int hs_flag(struct hashset *_set_);
_Bool hs_resize(struct hashset *_set_, size_t capacity);
struct hashset *hs_copy_of(struct hashset *_set_);
_Bool hs_equals(struct hashset *_set1_, struct hashset *_set2_);
struct hashset_iter
{
struct hashset *target;
size_t cursor;
size_t index;
size_t first;
size_t last;
_Bool start;
_Bool end;
};
struct hashset_iter hs_iter_start(struct hashset *target);
struct hashset_iter hs_iter_end(struct hashset *target);
_Bool hs_iter_at_start(struct hashset_iter *iter);
_Bool hs_iter_at_end(struct hashset_iter *iter);
_Bool hs_iter_to_start(struct hashset_iter *iter);
_Bool hs_iter_to_end(struct hashset_iter *iter);
_Bool hs_iter_next(struct hashset_iter *iter);
_Bool hs_iter_prev(struct hashset_iter *iter);
_Bool hs_iter_advance(struct hashset_iter *iter, size_t steps);
_Bool hs_iter_rewind(struct hashset_iter *iter, size_t steps);
_Bool hs_iter_go_to(struct hashset_iter *iter, size_t index);
size_t hs_iter_value(struct hashset_iter *iter);
size_t hs_iter_index(struct hashset_iter *iter);
struct hashset *hs_union(struct hashset *_set1_, struct hashset *_set2_);
struct hashset *hs_intersection(struct hashset *_set1_, struct hashset *_set2_);
struct hashset *hs_difference(struct hashset *_set1_, struct hashset *_set2_);
struct hashset *hs_symmetric_difference(struct hashset *_set1_, struct hashset *_set2_);
_Bool hs_is_subset(struct hashset *_set1_, struct hashset *_set2_);
_Bool hs_is_superset(struct hashset *_set1_, struct hashset *_set2_);
_Bool hs_is_proper_subset(struct hashset *_set1_, struct hashset *_set2_);
_Bool hs_is_proper_superset(struct hashset *_set1_, struct hashset *_set2_);
_Bool hs_is_disjointset(struct hashset *_set1_, struct hashset *_set2_);
_Bool hs_to_string(struct hashset *_set_, FILE *fptr);
_Bool hs_print(struct hashset *_set_, FILE *fptr, const char *start, const char *separator, const char *end);
#endif /* CMC_CMC_HASHSET_TEST_H */
+68
View File
@@ -0,0 +1,68 @@
#ifndef CMC_CMC_HEAP_TEST_H
#define CMC_CMC_HEAP_TEST_H
#include "macro_collections.h"
struct heap
{
size_t *buffer;
size_t capacity;
size_t count;
enum cmc_heap_order HO;
int flag;
struct heap_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct heap_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 heap *h_new(size_t capacity, enum cmc_heap_order HO, struct heap_fval *f_val);
struct heap *h_new_custom(size_t capacity, enum cmc_heap_order HO, struct heap_fval *f_val,
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
void h_clear(struct heap *_heap_);
void h_free(struct heap *_heap_);
void h_customize(struct heap *_heap_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool h_insert(struct heap *_heap_, size_t value);
_Bool h_remove(struct heap *_heap_);
size_t h_peek(struct heap *_heap_);
_Bool h_contains(struct heap *_heap_, size_t value);
_Bool h_empty(struct heap *_heap_);
_Bool h_full(struct heap *_heap_);
size_t h_count(struct heap *_heap_);
size_t h_capacity(struct heap *_heap_);
int h_flag(struct heap *_heap_);
_Bool h_resize(struct heap *_heap_, size_t capacity);
struct heap *h_copy_of(struct heap *_heap_);
_Bool h_equals(struct heap *_heap1_, struct heap *_heap2_);
struct heap_iter
{
struct heap *target;
size_t cursor;
_Bool start;
_Bool end;
};
struct heap_iter h_iter_start(struct heap *target);
struct heap_iter h_iter_end(struct heap *target);
_Bool h_iter_at_start(struct heap_iter *iter);
_Bool h_iter_at_end(struct heap_iter *iter);
_Bool h_iter_to_start(struct heap_iter *iter);
_Bool h_iter_to_end(struct heap_iter *iter);
_Bool h_iter_next(struct heap_iter *iter);
_Bool h_iter_prev(struct heap_iter *iter);
_Bool h_iter_advance(struct heap_iter *iter, size_t steps);
_Bool h_iter_rewind(struct heap_iter *iter, size_t steps);
_Bool h_iter_go_to(struct heap_iter *iter, size_t index);
size_t h_iter_value(struct heap_iter *iter);
size_t h_iter_index(struct heap_iter *iter);
_Bool h_to_string(struct heap *_heap_, FILE *fptr);
_Bool h_print(struct heap *_heap_, FILE *fptr, const char *start, const char *separator, const char *end);
#endif /* CMC_CMC_HEAP_TEST_H */
+72
View File
@@ -0,0 +1,72 @@
#ifndef CMC_CMC_INTERVALHEAP_TEST_H
#define CMC_CMC_INTERVALHEAP_TEST_H
#include "macro_collections.h"
struct intervalheap
{
size_t (*buffer)[2];
size_t capacity;
size_t size;
size_t count;
int flag;
struct intervalheap_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct intervalheap_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 intervalheap *ih_new(size_t capacity, struct intervalheap_fval *f_val);
struct intervalheap *ih_new_custom(size_t capacity, struct intervalheap_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void ih_clear(struct intervalheap *_heap_);
void ih_free(struct intervalheap *_heap_);
void ih_customize(struct intervalheap *_heap_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool ih_insert(struct intervalheap *_heap_, size_t value);
_Bool ih_remove_max(struct intervalheap *_heap_);
_Bool ih_remove_min(struct intervalheap *_heap_);
_Bool ih_update_max(struct intervalheap *_heap_, size_t value);
_Bool ih_update_min(struct intervalheap *_heap_, size_t value);
size_t ih_max(struct intervalheap *_heap_);
size_t ih_min(struct intervalheap *_heap_);
_Bool ih_contains(struct intervalheap *_heap_, size_t value);
_Bool ih_empty(struct intervalheap *_heap_);
_Bool ih_full(struct intervalheap *_heap_);
size_t ih_count(struct intervalheap *_heap_);
size_t ih_capacity(struct intervalheap *_heap_);
int ih_flag(struct intervalheap *_heap_);
_Bool ih_resize(struct intervalheap *_heap_, size_t capacity);
struct intervalheap *ih_copy_of(struct intervalheap *_heap_);
_Bool ih_equals(struct intervalheap *_heap1_, struct intervalheap *_heap2_);
struct intervalheap_iter
{
struct intervalheap *target;
size_t cursor;
_Bool start;
_Bool end;
};
struct intervalheap_iter ih_iter_start(struct intervalheap *target);
struct intervalheap_iter ih_iter_end(struct intervalheap *target);
_Bool ih_iter_at_start(struct intervalheap_iter *iter);
_Bool ih_iter_at_end(struct intervalheap_iter *iter);
_Bool ih_iter_to_start(struct intervalheap_iter *iter);
_Bool ih_iter_to_end(struct intervalheap_iter *iter);
_Bool ih_iter_next(struct intervalheap_iter *iter);
_Bool ih_iter_prev(struct intervalheap_iter *iter);
_Bool ih_iter_advance(struct intervalheap_iter *iter, size_t steps);
_Bool ih_iter_rewind(struct intervalheap_iter *iter, size_t steps);
_Bool ih_iter_go_to(struct intervalheap_iter *iter, size_t index);
size_t ih_iter_value(struct intervalheap_iter *iter);
size_t ih_iter_index(struct intervalheap_iter *iter);
_Bool ih_to_string(struct intervalheap *_heap_, FILE *fptr);
_Bool ih_print(struct intervalheap *_heap_, FILE *fptr, const char *start, const char *separator, const char *end);
#endif /* CMC_CMC_INTERVALHEAP_TEST_H */
+92
View File
@@ -0,0 +1,92 @@
#ifndef CMC_CMC_LINKEDLIST_TEST_H
#define CMC_CMC_LINKEDLIST_TEST_H
#include "macro_collections.h"
struct linkedlist
{
struct linkedlist_node *head;
struct linkedlist_node *tail;
size_t count;
int flag;
struct linkedlist_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct linkedlist_node
{
size_t value;
struct linkedlist_node *next;
struct linkedlist_node *prev;
};
struct linkedlist_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 linkedlist *ll_new(struct linkedlist_fval *f_val);
struct linkedlist *ll_new_custom(struct linkedlist_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void ll_clear(struct linkedlist *_list_);
void ll_free(struct linkedlist *_list_);
void ll_customize(struct linkedlist *_list_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool ll_push_front(struct linkedlist *_list_, size_t value);
_Bool ll_push_at(struct linkedlist *_list_, size_t value, size_t index);
_Bool ll_push_back(struct linkedlist *_list_, size_t value);
_Bool ll_pop_front(struct linkedlist *_list_);
_Bool ll_pop_at(struct linkedlist *_list_, size_t index);
_Bool ll_pop_back(struct linkedlist *_list_);
size_t ll_front(struct linkedlist *_list_);
size_t ll_get(struct linkedlist *_list_, size_t index);
size_t *ll_get_ref(struct linkedlist *_list_, size_t index);
size_t ll_back(struct linkedlist *_list_);
_Bool ll_contains(struct linkedlist *_list_, size_t value);
_Bool ll_empty(struct linkedlist *_list_);
size_t ll_count(struct linkedlist *_list_);
int ll_flag(struct linkedlist *_list_);
struct linkedlist *ll_copy_of(struct linkedlist *_list_);
_Bool ll_equals(struct linkedlist *_list1_, struct linkedlist *_list2_);
struct linkedlist_iter
{
struct linkedlist *target;
struct linkedlist_node *cursor;
size_t index;
_Bool start;
_Bool end;
};
struct linkedlist_iter ll_iter_start(struct linkedlist *target);
struct linkedlist_iter ll_iter_end(struct linkedlist *target);
_Bool ll_iter_at_start(struct linkedlist_iter *iter);
_Bool ll_iter_at_end(struct linkedlist_iter *iter);
_Bool ll_iter_to_start(struct linkedlist_iter *iter);
_Bool ll_iter_to_end(struct linkedlist_iter *iter);
_Bool ll_iter_next(struct linkedlist_iter *iter);
_Bool ll_iter_prev(struct linkedlist_iter *iter);
_Bool ll_iter_advance(struct linkedlist_iter *iter, size_t steps);
_Bool ll_iter_rewind(struct linkedlist_iter *iter, size_t steps);
_Bool ll_iter_go_to(struct linkedlist_iter *iter, size_t index);
size_t ll_iter_value(struct linkedlist_iter *iter);
size_t *ll_iter_rvalue(struct linkedlist_iter *iter);
size_t ll_iter_index(struct linkedlist_iter *iter);
struct linkedlist_node *ll_iter_node(struct linkedlist_iter *iter);
struct linkedlist_node *ll_new_node(struct linkedlist *_list_, size_t value);
void ll_free_node(struct linkedlist *_list_, struct linkedlist_node *_node_);
struct linkedlist_node *ll_head(struct linkedlist *_list_);
struct linkedlist_node *ll_get_node(struct linkedlist *_list_, size_t index);
struct linkedlist_node *ll_tail(struct linkedlist *_list_);
_Bool ll_add_next(struct linkedlist *_owner_, struct linkedlist_node *_node_, size_t value);
_Bool ll_add_prev(struct linkedlist *_owner_, struct linkedlist_node *_node_, size_t value);
_Bool ll_del_next(struct linkedlist *_owner_, struct linkedlist_node *_node_);
_Bool ll_del_curr(struct linkedlist *_owner_, struct linkedlist_node *_node_);
_Bool ll_del_prev(struct linkedlist *_owner_, struct linkedlist_node *_node_);
struct linkedlist_node *ll_next_node(struct linkedlist_node *_node_);
struct linkedlist_node *ll_prev_node(struct linkedlist_node *_node_);
_Bool ll_to_string(struct linkedlist *_list_, FILE *fptr);
_Bool ll_print(struct linkedlist *_list_, FILE *fptr, const char *start, const char *separator, const char *end);
#endif /* CMC_CMC_LINKEDLIST_TEST_H */
+82
View File
@@ -0,0 +1,82 @@
#ifndef CMC_CMC_LIST_TEST_H
#define CMC_CMC_LIST_TEST_H
#include "macro_collections.h"
struct list
{
size_t *buffer;
size_t capacity;
size_t count;
int flag;
struct list_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct list_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 list *l_new(size_t capacity, struct list_fval *f_val);
struct list *l_new_custom(size_t capacity, struct list_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void l_clear(struct list *_list_);
void l_free(struct list *_list_);
void l_customize(struct list *_list_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool l_push_front(struct list *_list_, size_t value);
_Bool l_push_at(struct list *_list_, size_t value, size_t index);
_Bool l_push_back(struct list *_list_, size_t value);
_Bool l_pop_front(struct list *_list_);
_Bool l_pop_at(struct list *_list_, size_t index);
_Bool l_pop_back(struct list *_list_);
size_t l_front(struct list *_list_);
size_t l_get(struct list *_list_, size_t index);
size_t *l_get_ref(struct list *_list_, size_t index);
size_t l_back(struct list *_list_);
size_t l_index_of(struct list *_list_, size_t value, _Bool from_start);
_Bool l_contains(struct list *_list_, size_t value);
_Bool l_empty(struct list *_list_);
_Bool l_full(struct list *_list_);
size_t l_count(struct list *_list_);
_Bool l_fits(struct list *_list_, size_t size);
size_t l_capacity(struct list *_list_);
int l_flag(struct list *_list_);
_Bool l_resize(struct list *_list_, size_t capacity);
struct list *l_copy_of(struct list *_list_);
_Bool l_equals(struct list *_list1_, struct list *_list2_);
struct list_iter
{
struct list *target;
size_t cursor;
_Bool start;
_Bool end;
};
struct list_iter l_iter_start(struct list *target);
struct list_iter l_iter_end(struct list *target);
_Bool l_iter_at_start(struct list_iter *iter);
_Bool l_iter_at_end(struct list_iter *iter);
_Bool l_iter_to_start(struct list_iter *iter);
_Bool l_iter_to_end(struct list_iter *iter);
_Bool l_iter_next(struct list_iter *iter);
_Bool l_iter_prev(struct list_iter *iter);
_Bool l_iter_advance(struct list_iter *iter, size_t steps);
_Bool l_iter_rewind(struct list_iter *iter, size_t steps);
_Bool l_iter_go_to(struct list_iter *iter, size_t index);
size_t l_iter_value(struct list_iter *iter);
size_t *l_iter_rvalue(struct list_iter *iter);
size_t l_iter_index(struct list_iter *iter);
_Bool l_seq_push_front(struct list *_list_, size_t *values, size_t size);
_Bool l_seq_push_at(struct list *_list_, size_t *values, size_t size, size_t index);
_Bool l_seq_push_back(struct list *_list_, size_t *values, size_t size);
_Bool l_seq_pop_at(struct list *_list_, size_t from, size_t to);
struct list *l_seq_sublist(struct list *_list_, size_t from, size_t to);
_Bool l_to_string(struct list *_list_, FILE *fptr);
_Bool l_print(struct list *_list_, FILE *fptr, const char *start, const char *separator, const char *end);
#endif /* CMC_CMC_LIST_TEST_H */
+71
View File
@@ -0,0 +1,71 @@
#ifndef CMC_CMC_QUEUE_TEST_H
#define CMC_CMC_QUEUE_TEST_H
#include "macro_collections.h"
struct queue
{
size_t *buffer;
size_t capacity;
size_t count;
size_t front;
size_t back;
int flag;
struct queue_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct queue_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 queue_iter
{
struct queue *target;
size_t cursor;
size_t index;
_Bool start;
_Bool end;
};
struct queue *q_new(size_t capacity, struct queue_fval *f_val);
struct queue *q_new_custom(size_t capacity, struct queue_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void q_clear(struct queue *_queue_);
void q_free(struct queue *_queue_);
void q_customize(struct queue *_queue_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool q_enqueue(struct queue *_queue_, size_t value);
_Bool q_dequeue(struct queue *_queue_);
size_t q_peek(struct queue *_queue_);
_Bool q_contains(struct queue *_queue_, size_t value);
_Bool q_empty(struct queue *_queue_);
_Bool q_full(struct queue *_queue_);
size_t q_count(struct queue *_queue_);
size_t q_capacity(struct queue *_queue_);
int q_flag(struct queue *_queue_);
_Bool q_resize(struct queue *_queue_, size_t capacity);
struct queue *q_copy_of(struct queue *_queue_);
_Bool q_equals(struct queue *_queue1_, struct queue *_queue2_);
struct queue_iter q_iter_start(struct queue *target);
struct queue_iter q_iter_end(struct queue *target);
_Bool q_iter_at_start(struct queue_iter *iter);
_Bool q_iter_at_end(struct queue_iter *iter);
_Bool q_iter_to_start(struct queue_iter *iter);
_Bool q_iter_to_end(struct queue_iter *iter);
_Bool q_iter_next(struct queue_iter *iter);
_Bool q_iter_prev(struct queue_iter *iter);
_Bool q_iter_advance(struct queue_iter *iter, size_t steps);
_Bool q_iter_rewind(struct queue_iter *iter, size_t steps);
_Bool q_iter_go_to(struct queue_iter *iter, size_t index);
size_t q_iter_value(struct queue_iter *iter);
size_t *q_iter_rvalue(struct queue_iter *iter);
size_t q_iter_index(struct queue_iter *iter);
_Bool q_to_string(struct queue *_queue_, FILE *fptr);
_Bool q_print(struct queue *_queue_, FILE *fptr, const char *start, const char *separator, const char *end);
#endif /* CMC_CMC_QUEUE_TEST_H */
+72
View File
@@ -0,0 +1,72 @@
#ifndef CMC_CMC_SORTEDLIST_TEST_H
#define CMC_CMC_SORTEDLIST_TEST_H
#include "macro_collections.h"
struct sortedlist
{
size_t *buffer;
size_t capacity;
size_t count;
_Bool is_sorted;
int flag;
struct sortedlist_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct sortedlist_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 sortedlist *sl_new(size_t capacity, struct sortedlist_fval *f_val);
struct sortedlist *sl_new_custom(size_t capacity, struct sortedlist_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void sl_clear(struct sortedlist *_list_);
void sl_free(struct sortedlist *_list_);
void sl_customize(struct sortedlist *_list_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool sl_insert(struct sortedlist *_list_, size_t value);
_Bool sl_remove(struct sortedlist *_list_, size_t index);
size_t sl_max(struct sortedlist *_list_);
size_t sl_min(struct sortedlist *_list_);
size_t sl_get(struct sortedlist *_list_, size_t index);
size_t sl_index_of(struct sortedlist *_list_, size_t value, _Bool from_start);
_Bool sl_contains(struct sortedlist *_list_, size_t value);
_Bool sl_empty(struct sortedlist *_list_);
_Bool sl_full(struct sortedlist *_list_);
size_t sl_count(struct sortedlist *_list_);
size_t sl_capacity(struct sortedlist *_list_);
int sl_flag(struct sortedlist *_list_);
_Bool sl_resize(struct sortedlist *_list_, size_t capacity);
void sl_sort(struct sortedlist *_list_);
struct sortedlist *sl_copy_of(struct sortedlist *_list_);
_Bool sl_equals(struct sortedlist *_list1_, struct sortedlist *_list2_);
struct sortedlist_iter
{
struct sortedlist *target;
size_t cursor;
_Bool start;
_Bool end;
};
struct sortedlist_iter sl_iter_start(struct sortedlist *target);
struct sortedlist_iter sl_iter_end(struct sortedlist *target);
_Bool sl_iter_at_start(struct sortedlist_iter *iter);
_Bool sl_iter_at_end(struct sortedlist_iter *iter);
_Bool sl_iter_to_start(struct sortedlist_iter *iter);
_Bool sl_iter_to_end(struct sortedlist_iter *iter);
_Bool sl_iter_next(struct sortedlist_iter *iter);
_Bool sl_iter_prev(struct sortedlist_iter *iter);
_Bool sl_iter_advance(struct sortedlist_iter *iter, size_t steps);
_Bool sl_iter_rewind(struct sortedlist_iter *iter, size_t steps);
_Bool sl_iter_go_to(struct sortedlist_iter *iter, size_t index);
size_t sl_iter_value(struct sortedlist_iter *iter);
size_t sl_iter_index(struct sortedlist_iter *iter);
_Bool sl_to_string(struct sortedlist *_list_, FILE *fptr);
_Bool sl_print(struct sortedlist *_list_, FILE *fptr, const char *start, const char *separator, const char *end);
#endif /* CMC_CMC_SORTEDLIST_TEST_H */
+68
View File
@@ -0,0 +1,68 @@
#ifndef CMC_CMC_STACK_TEST_H
#define CMC_CMC_STACK_TEST_H
#include "macro_collections.h"
struct stack
{
size_t *buffer;
size_t capacity;
size_t count;
int flag;
struct stack_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct stack_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 stack *s_new(size_t capacity, struct stack_fval *f_val);
struct stack *s_new_custom(size_t capacity, struct stack_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void s_clear(struct stack *_stack_);
void s_free(struct stack *_stack_);
void s_customize(struct stack *_stack_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool s_push(struct stack *_stack_, size_t value);
_Bool s_pop(struct stack *_stack_);
size_t s_top(struct stack *_stack_);
_Bool s_contains(struct stack *_stack_, size_t value);
_Bool s_empty(struct stack *_stack_);
_Bool s_full(struct stack *_stack_);
size_t s_count(struct stack *_stack_);
size_t s_capacity(struct stack *_stack_);
int s_flag(struct stack *_stack_);
_Bool s_resize(struct stack *_stack_, size_t capacity);
struct stack *s_copy_of(struct stack *_stack_);
_Bool s_equals(struct stack *_stack1_, struct stack *_stack2_);
struct stack_iter
{
struct stack *target;
size_t cursor;
_Bool start;
_Bool end;
};
struct stack_iter s_iter_start(struct stack *target);
struct stack_iter s_iter_end(struct stack *target);
_Bool s_iter_at_start(struct stack_iter *iter);
_Bool s_iter_at_end(struct stack_iter *iter);
_Bool s_iter_to_start(struct stack_iter *iter);
_Bool s_iter_to_end(struct stack_iter *iter);
_Bool s_iter_next(struct stack_iter *iter);
_Bool s_iter_prev(struct stack_iter *iter);
_Bool s_iter_advance(struct stack_iter *iter, size_t steps);
_Bool s_iter_rewind(struct stack_iter *iter, size_t steps);
_Bool s_iter_go_to(struct stack_iter *iter, size_t index);
size_t s_iter_value(struct stack_iter *iter);
size_t *s_iter_rvalue(struct stack_iter *iter);
size_t s_iter_index(struct stack_iter *iter);
_Bool s_to_string(struct stack *_stack_, FILE *fptr);
_Bool s_print(struct stack *_stack_, FILE *fptr, const char *start, const char *separator, const char *end);
#endif /* CMC_CMC_STACK_TEST_H */
+92
View File
@@ -0,0 +1,92 @@
#ifndef CMC_CMC_TREEMAP_TEST_H
#define CMC_CMC_TREEMAP_TEST_H
#include "macro_collections.h"
struct treemap
{
struct treemap_node *root;
size_t count;
int flag;
struct treemap_fkey *f_key;
struct treemap_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct treemap_node
{
size_t key;
size_t value;
unsigned char height;
struct treemap_node *right;
struct treemap_node *left;
struct treemap_node *parent;
};
struct treemap_fkey
{
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 treemap_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 treemap *tm_new(struct treemap_fkey *f_key, struct treemap_fval *f_val);
struct treemap *tm_new_custom(struct treemap_fkey *f_key, struct treemap_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void tm_clear(struct treemap *_map_);
void tm_free(struct treemap *_map_);
void tm_customize(struct treemap *_map_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool tm_insert(struct treemap *_map_, size_t key, size_t value);
_Bool tm_update(struct treemap *_map_, size_t key, size_t new_value, size_t *old_value);
_Bool tm_remove(struct treemap *_map_, size_t key, size_t *out_value);
_Bool tm_max(struct treemap *_map_, size_t *key, size_t *value);
_Bool tm_min(struct treemap *_map_, size_t *key, size_t *value);
size_t tm_get(struct treemap *_map_, size_t key);
size_t *tm_get_ref(struct treemap *_map_, size_t key);
_Bool tm_contains(struct treemap *_map_, size_t key);
_Bool tm_empty(struct treemap *_map_);
size_t tm_count(struct treemap *_map_);
int tm_flag(struct treemap *_map_);
struct treemap *tm_copy_of(struct treemap *_map_);
_Bool tm_equals(struct treemap *_map1_, struct treemap *_map2_);
struct treemap_iter
{
struct treemap *target;
struct treemap_node *cursor;
struct treemap_node *first;
struct treemap_node *last;
size_t index;
_Bool start;
_Bool end;
};
struct treemap_iter tm_iter_start(struct treemap *target);
struct treemap_iter tm_iter_end(struct treemap *target);
_Bool tm_iter_at_start(struct treemap_iter *iter);
_Bool tm_iter_at_end(struct treemap_iter *iter);
_Bool tm_iter_to_start(struct treemap_iter *iter);
_Bool tm_iter_to_end(struct treemap_iter *iter);
_Bool tm_iter_next(struct treemap_iter *iter);
_Bool tm_iter_prev(struct treemap_iter *iter);
_Bool tm_iter_advance(struct treemap_iter *iter, size_t steps);
_Bool tm_iter_rewind(struct treemap_iter *iter, size_t steps);
_Bool tm_iter_go_to(struct treemap_iter *iter, size_t index);
size_t tm_iter_key(struct treemap_iter *iter);
size_t tm_iter_value(struct treemap_iter *iter);
size_t *tm_iter_rvalue(struct treemap_iter *iter);
size_t tm_iter_index(struct treemap_iter *iter);
_Bool tm_to_string(struct treemap *_map_, FILE *fptr);
_Bool tm_print(struct treemap *_map_, FILE *fptr, const char *start, const char *separator, const char *end,
const char *key_val_sep);
#endif /* CMC_CMC_TREEMAP_TEST_H */
+84
View File
@@ -0,0 +1,84 @@
#ifndef CMC_CMC_TREESET_TEST_H
#define CMC_CMC_TREESET_TEST_H
#include "macro_collections.h"
struct treeset
{
struct treeset_node *root;
size_t count;
int flag;
struct treeset_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct treeset_node
{
size_t value;
unsigned char height;
struct treeset_node *right;
struct treeset_node *left;
struct treeset_node *parent;
};
struct treeset_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 treeset_iter
{
struct treeset *target;
struct treeset_node *cursor;
struct treeset_node *first;
struct treeset_node *last;
size_t index;
_Bool start;
_Bool end;
};
struct treeset *ts_new(struct treeset_fval *f_val);
struct treeset *ts_new_custom(struct treeset_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void ts_clear(struct treeset *_set_);
void ts_free(struct treeset *_set_);
void ts_customize(struct treeset *_set_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool ts_insert(struct treeset *_set_, size_t value);
_Bool ts_remove(struct treeset *_set_, size_t value);
_Bool ts_max(struct treeset *_set_, size_t *value);
_Bool ts_min(struct treeset *_set_, size_t *value);
_Bool ts_contains(struct treeset *_set_, size_t value);
_Bool ts_empty(struct treeset *_set_);
size_t ts_count(struct treeset *_set_);
int ts_flag(struct treeset *_set_);
struct treeset *ts_copy_of(struct treeset *_set_);
_Bool ts_equals(struct treeset *_set1_, struct treeset *_set2_);
struct treeset *ts_union(struct treeset *_set1_, struct treeset *_set2_);
struct treeset *ts_intersection(struct treeset *_set1_, struct treeset *_set2_);
struct treeset *ts_difference(struct treeset *_set1_, struct treeset *_set2_);
struct treeset *ts_symmetric_difference(struct treeset *_set1_, struct treeset *_set2_);
_Bool ts_is_subset(struct treeset *_set1_, struct treeset *_set2_);
_Bool ts_is_superset(struct treeset *_set1_, struct treeset *_set2_);
_Bool ts_is_proper_subset(struct treeset *_set1_, struct treeset *_set2_);
_Bool ts_is_proper_superset(struct treeset *_set1_, struct treeset *_set2_);
_Bool ts_is_disjointset(struct treeset *_set1_, struct treeset *_set2_);
struct treeset_iter ts_iter_start(struct treeset *target);
struct treeset_iter ts_iter_end(struct treeset *target);
_Bool ts_iter_at_start(struct treeset_iter *iter);
_Bool ts_iter_at_end(struct treeset_iter *iter);
_Bool ts_iter_to_start(struct treeset_iter *iter);
_Bool ts_iter_to_end(struct treeset_iter *iter);
_Bool ts_iter_next(struct treeset_iter *iter);
_Bool ts_iter_prev(struct treeset_iter *iter);
_Bool ts_iter_advance(struct treeset_iter *iter, size_t steps);
_Bool ts_iter_rewind(struct treeset_iter *iter, size_t steps);
_Bool ts_iter_go_to(struct treeset_iter *iter, size_t index);
size_t ts_iter_value(struct treeset_iter *iter);
size_t ts_iter_index(struct treeset_iter *iter);
_Bool ts_to_string(struct treeset *_set_, FILE *fptr);
_Bool ts_print(struct treeset *_set_, FILE *fptr, const char *start, const char *separator, const char *end);
#endif /* CMC_CMC_TREESET_TEST_H */
+102
View File
@@ -0,0 +1,102 @@
#include <stdio.h>
#include <inttypes.h>
#include "unt/cmc/bitset.h"
#include "unt/cmc/deque.h"
#include "unt/cmc/hashbidimap.h"
#include "unt/cmc/hashmap.h"
#include "unt/cmc/hashmultimap.h"
#include "unt/cmc/hashmultiset.h"
#include "unt/cmc/hashset.h"
#include "unt/cmc/heap.h"
#include "unt/cmc/intervalheap.h"
#include "unt/cmc/linkedlist.h"
#include "unt/cmc/list.h"
#include "unt/cmc/queue.h"
#include "unt/cmc/sortedlist.h"
#include "unt/cmc/stack.h"
#include "unt/cmc/treemap.h"
#include "unt/cmc/treeset.h"
#include "unt/utl/foreach.h"
#include "utl/timer.h"
#include "utl/assert.h"
#include "./unt/utl.h"
#define cmc_run(unit, unit_fails, test_fails) \
do \
{ \
uintmax_t f = unit(); \
if (f != 0) \
unit_fails += 1; \
test_fails += f; \
} while (0)
int main(void)
{
// clang-format off
printf(" +---------------------------------------------------------------+\n");
printf(" | C Macro Collections Library |\n");
printf(" | |\n");
printf(" | Test Suite |\n");
printf(" | |\n");
printf(" | https://github.com/LeoVen/C-Macro-Collections |\n");
printf(" | Leonardo Vencovsky (leonardo.vencovsky@gmail.com) |\n");
printf(" +---------------------------------------------------------------+\n\n");
// clang-format on
struct cmc_timer timer;
cmc_timer_start(timer);
uintmax_t tests = 0, units = 0;
cmc_run(CMCBitSet, units, tests);
cmc_run(CMCBitSetIter, units, tests);
cmc_run(CMCDeque, units, tests);
cmc_run(CMCDequeIter, units, tests);
cmc_run(CMCHashBidiMap, units, tests);
cmc_run(CMCHashBidiMapIter, units, tests);
cmc_run(CMCHashMap, units, tests);
cmc_run(CMCHashMapIter, units, tests);
cmc_run(CMCHashMultiMap, units, tests);
cmc_run(CMCHashMultiMapIter, units, tests);
cmc_run(CMCHashMultiSet, units, tests);
cmc_run(CMCHashMultiSetIter, units, tests);
cmc_run(CMCHashSet, units, tests);
cmc_run(CMCHashSetIter, units, tests);
cmc_run(CMCHeap, units, tests);
cmc_run(CMCHeapIter, units, tests);
cmc_run(CMCIntervalHeap, units, tests);
cmc_run(CMCIntervalHeapIter, units, tests);
cmc_run(CMCLinkedList, units, tests);
cmc_run(CMCLinkedListIter, units, tests);
cmc_run(CMCList, units, tests);
cmc_run(CMCListIter, units, tests);
cmc_run(CMCQueue, units, tests);
cmc_run(CMCQueueIter, units, tests);
cmc_run(CMCSortedList, units, tests);
cmc_run(CMCSortedListIter, units, tests);
cmc_run(CMCStack, units, tests);
cmc_run(CMCStackIter, units, tests);
cmc_run(CMCTreeMap, units, tests);
cmc_run(CMCTreeMapIter, units, tests);
cmc_run(CMCTreeSet, units, tests);
cmc_run(CMCTreeSetIter, units, tests);
cmc_run(ForEach, units, tests);
cmc_timer_stop(timer);
printf(" +---------------------------------------------------------------+\n");
printf(" | SUMMARY |\n");
printf(" +---------------------------------------------------------------+\n");
printf(" | Total Units Failed : %25" PRIuMAX " units |\n", units);
printf(" | Total Tests Failed : %25" PRIuMAX " tests |\n", tests);
printf(" | Total Asserts Failed : %25" PRIuMAX " asserts |\n", cmc_assert_failed);
printf(" | Total Runtime : %25.0lf milliseconds |\n", timer.result);
printf(" +---------------------------------------------------------------+\n");
return tests;
}
-107
View File
@@ -1,107 +0,0 @@
CC = gcc
CFLAGS = -std=c11 -Wall -Wextra
CFLAGS += -Wno-missing-braces
DBFLAGS = -g3
CVFLAGS = --coverage -O0
INCLUDE = ../../src/
UNIT = ./unt
main: FORCE
$(CC) main.c -o main.exe $(CFLAGS) $(CVFLAGS) -I $(INCLUDE) -DCMC_TEST_COLOR
./main.exe
gcov ./main.c
nocov: FORCE
$(CC) main.c -o main.exe $(CFLAGS) -I $(INCLUDE) -DCMC_TEST_COLOR
./main.exe
rm *.exe
bare: FORCE
$(CC) main.c -o main.exe $(CFLAGS) -I $(INCLUDE)
./main.exe
rm *.exe
debug: FORCE
$(CC) main.c -o main.exe $(CFLAGS) -I $(INCLUDE) -DCMC_TEST_COLOR $(DBFLAGS)
valgrind: debug
valgrind --leak-check=full ./main.exe
all: bitset deque hashbidimap hashmap hashmultimap hashmultiset hashset heap intervalheap linkedlist list queue sortedlist stack treemap treeset foreach
rm ./main.exe
bitset: $(UNIT)/bitset.c $(INCLUDE)/cmc/bitset.h
$(CC) $^ -o main.exe -I $(INCLUDE) -DCMC_TEST_MAIN -DCMC_TEST_COLOR -DCMC_BITSET_WORD_TYPE=uint8_t
./main.exe
$(CC) $^ -o main.exe -I $(INCLUDE) -DCMC_TEST_MAIN -DCMC_TEST_COLOR -DCMC_BITSET_WORD_TYPE=uint16_t
./main.exe
$(CC) $^ -o main.exe -I $(INCLUDE) -DCMC_TEST_MAIN -DCMC_TEST_COLOR -DCMC_BITSET_WORD_TYPE=uint32_t
./main.exe
$(CC) $^ -o main.exe -I $(INCLUDE) -DCMC_TEST_MAIN -DCMC_TEST_COLOR -DCMC_BITSET_WORD_TYPE=uint64_t
./main.exe
deque: $(UNIT)/deque.c $(INCLUDE)/cmc/deque.h
$(CC) $^ -o main.exe -I $(INCLUDE) -DCMC_TEST_MAIN -DCMC_TEST_COLOR
./main.exe
hashbidimap: $(UNIT)/hashbidimap.c $(INCLUDE)/cmc/hashbidimap.h
$(CC) $^ -o main.exe -I $(INCLUDE) -DCMC_TEST_MAIN -DCMC_TEST_COLOR
./main.exe
hashmap: $(UNIT)/hashmap.c $(INCLUDE)/cmc/hashmap.h
$(CC) $^ -o main.exe -I $(INCLUDE) -DCMC_TEST_MAIN -DCMC_TEST_COLOR
./main.exe
hashmultimap: $(UNIT)/hashmultimap.c $(INCLUDE)/cmc/hashmultimap.h
$(CC) $^ -o main.exe -I $(INCLUDE) -DCMC_TEST_MAIN -DCMC_TEST_COLOR
./main.exe
hashmultiset: $(UNIT)/hashmultiset.c $(INCLUDE)/cmc/hashmultiset.h
$(CC) $^ -o main.exe -I $(INCLUDE) -DCMC_TEST_MAIN -DCMC_TEST_COLOR
./main.exe
hashset: $(UNIT)/hashset.c $(INCLUDE)/cmc/hashset.h
$(CC) $^ -o main.exe -I $(INCLUDE) -DCMC_TEST_MAIN -DCMC_TEST_COLOR
./main.exe
heap: $(UNIT)/heap.c $(INCLUDE)/cmc/heap.h
$(CC) $^ -o main.exe -I $(INCLUDE) -DCMC_TEST_MAIN -DCMC_TEST_COLOR
./main.exe
intervalheap: $(UNIT)/intervalheap.c $(INCLUDE)/cmc/intervalheap.h
$(CC) $^ -o main.exe -I $(INCLUDE) -DCMC_TEST_MAIN -DCMC_TEST_COLOR
./main.exe
linkedlist: $(UNIT)/linkedlist.c $(INCLUDE)/cmc/linkedlist.h
$(CC) $^ -o main.exe -I $(INCLUDE) -DCMC_TEST_MAIN -DCMC_TEST_COLOR
./main.exe
list: $(UNIT)/list.c $(INCLUDE)/cmc/list.h
$(CC) $^ -o main.exe -I $(INCLUDE) -DCMC_TEST_MAIN -DCMC_TEST_COLOR
./main.exe
queue: $(UNIT)/queue.c $(INCLUDE)/cmc/queue.h
$(CC) $^ -o main.exe -I $(INCLUDE) -DCMC_TEST_MAIN -DCMC_TEST_COLOR
./main.exe
sortedlist: $(UNIT)/sortedlist.c $(INCLUDE)/cmc/sortedlist.h
$(CC) $^ -o main.exe -I $(INCLUDE) -DCMC_TEST_MAIN -DCMC_TEST_COLOR
./main.exe
stack: $(UNIT)/stack.c $(INCLUDE)/cmc/stack.h
$(CC) $^ -o main.exe -I $(INCLUDE) -DCMC_TEST_MAIN -DCMC_TEST_COLOR
./main.exe
treemap: $(UNIT)/treemap.c $(INCLUDE)/cmc/treemap.h
$(CC) $^ -o main.exe -I $(INCLUDE) -DCMC_TEST_MAIN -DCMC_TEST_COLOR
./main.exe
treeset: $(UNIT)/treeset.c $(INCLUDE)/cmc/treeset.h
$(CC) $^ -o main.exe -I $(INCLUDE) -DCMC_TEST_MAIN -DCMC_TEST_COLOR
./main.exe
foreach: $(UNIT)/foreach.c $(INCLUDE)/utl/foreach.h
$(CC) $^ -o main.exe -I $(INCLUDE) -DCMC_TEST_MAIN -DCMC_TEST_COLOR
./main.exe
FORCE:
-3
View File
@@ -1,3 +0,0 @@
# main
This folder hosts the main tests for the C Macro Collections Library.
-96
View File
@@ -1,96 +0,0 @@
#include "utl/timer.h"
#include "unt/bitset.c"
#include "unt/deque.c"
#include "unt/hashbidimap.c"
#include "unt/hashmap.c"
#include "unt/hashmultimap.c"
#include "unt/hashmultiset.c"
#include "unt/hashset.c"
#include "unt/heap.c"
#include "unt/intervalheap.c"
#include "unt/linkedlist.c"
#include "unt/list.c"
#include "unt/queue.c"
#include "unt/sortedlist.c"
#include "unt/stack.c"
#include "unt/treemap.c"
#include "unt/treeset.c"
#include "unt/foreach.c"
#define cmc_run(unit, unit_fails, test_fails) \
do \
{ \
uintmax_t f = unit(); \
if (f != 0) \
unit_fails += 1; \
test_fails += f; \
} while (0)
int main(void)
{
// clang-format off
printf(" +---------------------------------------------------------------+\n");
printf(" | C Macro Collections Library |\n");
printf(" | |\n");
printf(" | Test Suite |\n");
printf(" | |\n");
printf(" | https://github.com/LeoVen/C-Macro-Collections |\n");
printf(" | Leonardo Vencovsky (leonardo.vencovsky@gmail.com) |\n");
printf(" +---------------------------------------------------------------+\n\n");
// clang-format on
struct cmc_timer timer;
cmc_timer_start(timer);
uintmax_t tests = 0, units = 0;
cmc_run(BitSet, units, tests);
cmc_run(BitSetIter, units, tests);
cmc_run(Deque, units, tests);
cmc_run(DequeIter, units, tests);
cmc_run(HashBidiMap, units, tests);
cmc_run(HashBidiMapIter, units, tests);
cmc_run(HashMap, units, tests);
cmc_run(HashMapIter, units, tests);
cmc_run(HashMultiMap, units, tests);
cmc_run(HashMultiMapIter, units, tests);
cmc_run(HashMultiSet, units, tests);
cmc_run(HashMultiSetIter, units, tests);
cmc_run(HashSet, units, tests);
cmc_run(HashSetIter, units, tests);
cmc_run(Heap, units, tests);
cmc_run(HeapIter, units, tests);
cmc_run(IntervalHeap, units, tests);
cmc_run(IntervalHeapIter, units, tests);
cmc_run(LinkedList, units, tests);
cmc_run(LinkedListIter, units, tests);
cmc_run(List, units, tests);
cmc_run(ListIter, units, tests);
cmc_run(Queue, units, tests);
cmc_run(QueueIter, units, tests);
cmc_run(SortedList, units, tests);
cmc_run(SortedListIter, units, tests);
cmc_run(Stack, units, tests);
cmc_run(StackIter, units, tests);
cmc_run(TreeMap, units, tests);
cmc_run(TreeMapIter, units, tests);
cmc_run(TreeSet, units, tests);
cmc_run(TreeSetIter, units, tests);
cmc_run(ForEach, units, tests);
cmc_timer_stop(timer);
printf(" +---------------------------------------------------------------+\n");
printf(" | SUMMARY |\n");
printf(" +---------------------------------------------------------------+\n");
printf(" | Total Units Failed : %25" PRIuMAX " units |\n", units);
printf(" | Total Tests Failed : %25" PRIuMAX " tests |\n", tests);
printf(" | Total Asserts Failed : %25" PRIuMAX " asserts |\n", cmc_assert_failed);
printf(" | Total Runtime : %25.0lf milliseconds |\n", timer.result);
printf(" +---------------------------------------------------------------+\n");
return tests;
}
-15
View File
@@ -1,15 +0,0 @@
CC = gcc
CFLAGS = -std=c11 -Wall -Wextra
CFLAGS += -Wno-unused -Wno-missing-braces
main:
$(CC) -c collections.c -o collections.o $(CFLAGS)
$(CC) -c main.c -o main.o $(CFLAGS)
$(CC) collections.o main.o -o sep.exe
./sep.exe
clean:
rm *.o
clear:
rm *.o *.exe
-17
View File
@@ -1,17 +0,0 @@
#include "collections.h"
CMC_COLLECTION_GENERATE_SOURCE( BIDIMAP, bm, bmap, int, int)
CMC_COLLECTION_GENERATE_SOURCE( DEQUE, d, deque, /* K */, int)
CMC_COLLECTION_GENERATE_SOURCE( HASHMAP, hm, hmap, int, int)
CMC_COLLECTION_GENERATE_SOURCE( HASHSET, hs, hset, /* K */, int)
CMC_COLLECTION_GENERATE_SOURCE( HEAP, h, heap, /* K */, int)
CMC_COLLECTION_GENERATE_SOURCE(INTERVALHEAP, ih, iheap, /* K */, int)
CMC_COLLECTION_GENERATE_SOURCE( LINKEDLIST, ll, linked, /* K */, int)
CMC_COLLECTION_GENERATE_SOURCE( LIST, l, list, /* K */, int)
CMC_COLLECTION_GENERATE_SOURCE( MULTIMAP, mm, mmap, int, int)
CMC_COLLECTION_GENERATE_SOURCE( MULTISET, ms, mset, /* K */, int)
CMC_COLLECTION_GENERATE_SOURCE( QUEUE, q, queue, /* K */, int)
CMC_COLLECTION_GENERATE_SOURCE( SORTEDLIST, sl, slist, /* K */, int)
CMC_COLLECTION_GENERATE_SOURCE( STACK, s, stack, /* K */, int)
CMC_COLLECTION_GENERATE_SOURCE( TREESET, ts, tset, /* K */, int)
CMC_COLLECTION_GENERATE_SOURCE( TREEMAP, tm, tmap, int, int)
-17
View File
@@ -1,17 +0,0 @@
#include "../../src/macro_collections.h"
CMC_COLLECTION_GENERATE_HEADER( BIDIMAP, bm, bmap, int, int)
CMC_COLLECTION_GENERATE_HEADER( DEQUE, d, deque, /* K */, int)
CMC_COLLECTION_GENERATE_HEADER( HASHMAP, hm, hmap, int, int)
CMC_COLLECTION_GENERATE_HEADER( HASHSET, hs, hset, /* K */, int)
CMC_COLLECTION_GENERATE_HEADER( HEAP, h, heap, /* K */, int)
CMC_COLLECTION_GENERATE_HEADER(INTERVALHEAP, ih, iheap, /* K */, int)
CMC_COLLECTION_GENERATE_HEADER( LINKEDLIST, ll, linked, /* K */, int)
CMC_COLLECTION_GENERATE_HEADER( LIST, l, list, /* K */, int)
CMC_COLLECTION_GENERATE_HEADER( MULTIMAP, mm, mmap, int, int)
CMC_COLLECTION_GENERATE_HEADER( MULTISET, ms, mset, /* K */, int)
CMC_COLLECTION_GENERATE_HEADER( QUEUE, q, queue, /* K */, int)
CMC_COLLECTION_GENERATE_HEADER( SORTEDLIST, sl, slist, /* K */, int)
CMC_COLLECTION_GENERATE_HEADER( STACK, s, stack, /* K */, int)
CMC_COLLECTION_GENERATE_HEADER( TREESET, ts, tset, /* K */, int)
CMC_COLLECTION_GENERATE_HEADER( TREEMAP, tm, tmap, int, int)
-62
View File
@@ -1,62 +0,0 @@
#include "collections.h"
#include <stdio.h>
int intcmp(int a, int b)
{
return (a > b) - (a < b);
}
size_t inthash(int t)
{
size_t a = t;
a += ~(a << 15);
a ^= (a >> 10);
a += (a << 3);
a ^= (a >> 6);
a += ~(a << 11);
a ^= (a >> 16);
return a;
}
int main(void)
{
struct bmap *bm =
bm_new_custom(100, 0.7, &(struct bmap_ftab_key){ 0 },
&(struct bmap_ftab_val){ 0 }, NULL, NULL);
struct deque *d = d_new_custom(100, NULL, NULL);
struct hmap *hm = hm_new_custom(100, 0.6, NULL, NULL, NULL, NULL);
struct hset *hs = hs_new_custom(100, 0.6, NULL, NULL, NULL, NULL);
struct heap *h = h_new_custom(100, cmc_max_heap, NULL, NULL, NULL);
struct iheap *ih = ih_new_custom(100, NULL, NULL, NULL);
struct linked *ll = ll_new_custom(NULL, NULL);
struct list *l = l_new_custom(100, NULL, NULL);
struct mmap *mm = mm_new_custom(100, 0.8, NULL, NULL, NULL, NULL);
struct mset *ms = ms_new_custom(100, 0.6, NULL, NULL, NULL, NULL);
struct queue *q = q_new_custom(100, NULL, NULL);
struct slist *sl = sl_new_custom(100, NULL, NULL, NULL);
struct stack *s = s_new_custom(100, NULL, NULL);
struct tmap *tm = tm_new_custom(NULL, NULL, NULL);
struct tset *ts = ts_new_custom(NULL, NULL, NULL);
printf("+--------------------------------------------------+\n");
printf("| Separate Header and Source is Working |\n");
printf("+--------------------------------------------------+\n");
bm_free(bm);
d_free(d, NULL);
hm_free(hm, NULL);
hs_free(hs, NULL);
h_free(h, NULL);
ih_free(ih, NULL);
ll_free(ll, NULL);
l_free(l, NULL);
mm_free(mm, NULL);
ms_free(ms, NULL);
q_free(q, NULL);
sl_free(sl, NULL);
s_free(s, NULL);
tm_free(tm, NULL);
ts_free(ts, NULL);
return 0;
}
@@ -1,51 +1,6 @@
#ifndef CMC_TEST_SRC_BITSET
#define CMC_TEST_SRC_BITSET
#include "cmc/bitset.h"
struct bitset
{
cmc_bitset_word *buffer;
size_t capacity;
int flag;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct bitset_iter
{
struct bitset *target;
size_t cursor;
_Bool start;
_Bool end;
};
struct bitset *bs_new(size_t n_bits);
struct bitset *bs_new_custom(size_t n_bits, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
struct bitset bs_init(size_t n_bits);
struct bitset bs_init_custom(size_t n_bits, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
void bs_free(struct bitset *_bitset_);
void bs_release(struct bitset _bitset_);
void bs_customize(struct bitset *_bitset_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool bs_set(struct bitset *_bitset_, size_t bit_index);
_Bool bs_set_range(struct bitset *_bitset_, size_t from, size_t to);
_Bool bs_clear(struct bitset *_bitset_, size_t bit_index);
_Bool bs_clear_range(struct bitset *_bitset_, size_t from, size_t to);
_Bool bs_flip(struct bitset *_bitset_, size_t bit_index);
_Bool bs_flip_range(struct bitset *_bitset_, size_t from, size_t to);
_Bool bs_put(struct bitset *_bitset_, size_t bit_index, _Bool state);
_Bool bs_put_range(struct bitset *_bitset_, size_t from, size_t to, _Bool state);
_Bool bs_set_all(struct bitset *_bitset_);
_Bool bs_clear_all(struct bitset *_bitset_);
_Bool bs_flip_all(struct bitset *_bitset_);
_Bool bs_get(struct bitset *_bitset_, size_t bit_index);
_Bool bs_resize(struct bitset *_bitset_, size_t n_bits);
static inline size_t bs_bit_to_index(size_t idx)
{
static const size_t shift =
((sizeof(cmc_bitset_word) * 8) >> 6) > 0
? 6
: ((sizeof(cmc_bitset_word) * 8) >> 5) > 0 ? 5 : ((sizeof(cmc_bitset_word) * 8) >> 4) > 0 ? 4 : 3;
return idx >> shift;
}
_Bool bs_impl_resize(struct bitset *_bitset_, size_t n_bits, _Bool do_resize);
struct bitset *bs_new(size_t n_bits)
{
@@ -53,6 +8,7 @@ struct bitset *bs_new(size_t n_bits)
}
struct bitset *bs_new_custom(size_t n_bits, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks)
{
;
if (n_bits < 1)
return ((void *)0);
if (!alloc)
@@ -336,5 +292,3 @@ _Bool bs_impl_resize(struct bitset *_bitset_, size_t n_bits, _Bool do_resize)
_bitset_->flag = CMC_FLAG_OK;
return 1;
}
#endif /* CMC_TEST_SRC_BITSET */
@@ -1,78 +1,6 @@
#ifndef CMC_TEST_SRC_DEQUE
#define CMC_TEST_SRC_DEQUE
#include "cmc/deque.h"
struct deque
{
size_t *buffer;
size_t capacity;
size_t count;
size_t front;
size_t back;
int flag;
struct deque_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct deque_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 deque *d_new(size_t capacity, struct deque_fval *f_val);
struct deque *d_new_custom(size_t capacity, struct deque_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void d_clear(struct deque *_deque_);
void d_free(struct deque *_deque_);
void d_customize(struct deque *_deque_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool d_push_front(struct deque *_deque_, size_t value);
_Bool d_push_back(struct deque *_deque_, size_t value);
_Bool d_pop_front(struct deque *_deque_);
_Bool d_pop_back(struct deque *_deque_);
size_t d_front(struct deque *_deque_);
size_t d_back(struct deque *_deque_);
_Bool d_contains(struct deque *_deque_, size_t value);
_Bool d_empty(struct deque *_deque_);
_Bool d_full(struct deque *_deque_);
size_t d_count(struct deque *_deque_);
size_t d_capacity(struct deque *_deque_);
int d_flag(struct deque *_deque_);
_Bool d_resize(struct deque *_deque_, size_t capacity);
struct deque *d_copy_of(struct deque *_deque_);
_Bool d_equals(struct deque *_deque1_, struct deque *_deque2_);
struct deque d_init(size_t capacity, struct deque_fval *f_val);
struct deque d_init_custom(size_t capacity, struct deque_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void d_release(struct deque _deque_);
struct deque_iter
{
struct deque *target;
size_t cursor;
size_t index;
_Bool start;
_Bool end;
};
struct deque_iter d_iter_start(struct deque *target);
struct deque_iter d_iter_end(struct deque *target);
_Bool d_iter_at_start(struct deque_iter *iter);
_Bool d_iter_at_end(struct deque_iter *iter);
_Bool d_iter_to_start(struct deque_iter *iter);
_Bool d_iter_to_end(struct deque_iter *iter);
_Bool d_iter_next(struct deque_iter *iter);
_Bool d_iter_prev(struct deque_iter *iter);
_Bool d_iter_advance(struct deque_iter *iter, size_t steps);
_Bool d_iter_rewind(struct deque_iter *iter, size_t steps);
_Bool d_iter_go_to(struct deque_iter *iter, size_t index);
size_t d_iter_value(struct deque_iter *iter);
size_t *d_iter_rvalue(struct deque_iter *iter);
size_t d_iter_index(struct deque_iter *iter);
_Bool d_to_string(struct deque *_deque_, FILE *fptr);
_Bool d_print(struct deque *_deque_, FILE *fptr, const char *start, const char *separator, const char *end);
struct deque *d_new(size_t capacity, struct deque_fval *f_val)
{
return d_new_custom(capacity, f_val, ((void *)0), ((void *)0));
@@ -586,5 +514,3 @@ _Bool d_print(struct deque *_deque_, FILE *fptr, const char *start, const char *
fprintf(fptr, "%s", end);
return 1;
}
#endif /* CMC_TEST_SRC_DEQUE */
@@ -1,101 +1,6 @@
#ifndef CMC_TEST_SRC_HASHBIDIMAP
#define CMC_TEST_SRC_HASHBIDIMAP
#include "cmc/hashbidimap.h"
struct hashbidimap
{
struct hashbidimap_entry *(*buffer)[2];
size_t capacity;
size_t count;
double load;
int flag;
struct hashbidimap_fkey *f_key;
struct hashbidimap_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
struct hashbidimap_iter (*it_start)(struct hashbidimap *);
struct hashbidimap_iter (*it_end)(struct hashbidimap *);
};
struct hashbidimap_entry
{
size_t key;
size_t value;
size_t dist[2];
struct hashbidimap_entry **ref[2];
};
struct hashbidimap_fkey
{
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 hashbidimap_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 hashbidimap_iter
{
struct hashbidimap *target;
size_t cursor;
size_t index;
size_t first;
size_t last;
_Bool start;
_Bool end;
};
struct hashbidimap *hbm_new(size_t capacity, double load, struct hashbidimap_fkey *f_key,
struct hashbidimap_fval *f_val);
struct hashbidimap *hbm_new_custom(size_t capacity, double load, struct hashbidimap_fkey *f_key,
struct hashbidimap_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void hbm_clear(struct hashbidimap *_map_);
void hbm_free(struct hashbidimap *_map_);
void hbm_customize(struct hashbidimap *_map_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool hbm_insert(struct hashbidimap *_map_, size_t key, size_t value);
_Bool hbm_update_key(struct hashbidimap *_map_, size_t val, size_t new_key);
_Bool hbm_update_val(struct hashbidimap *_map_, size_t key, size_t new_val);
_Bool hbm_remove_by_key(struct hashbidimap *_map_, size_t key, size_t *out_key, size_t *out_val);
_Bool hbm_remove_by_val(struct hashbidimap *_map_, size_t val, size_t *out_key, size_t *out_val);
size_t hbm_get_key(struct hashbidimap *_map_, size_t val);
size_t hbm_get_val(struct hashbidimap *_map_, size_t key);
_Bool hbm_contains_key(struct hashbidimap *_map_, size_t key);
_Bool hbm_contains_val(struct hashbidimap *_map_, size_t val);
_Bool hbm_empty(struct hashbidimap *_map_);
_Bool hbm_full(struct hashbidimap *_map_);
size_t hbm_count(struct hashbidimap *_map_);
size_t hbm_capacity(struct hashbidimap *_map_);
double hbm_load(struct hashbidimap *_map_);
int hbm_flag(struct hashbidimap *_map_);
_Bool hbm_resize(struct hashbidimap *_map_, size_t capacity);
struct hashbidimap *hbm_copy_of(struct hashbidimap *_map_);
_Bool hbm_equals(struct hashbidimap *_map1_, struct hashbidimap *_map2_);
struct hashbidimap_iter *hbm_iter_new(struct hashbidimap *target);
void hbm_iter_free(struct hashbidimap_iter *iter);
void hbm_iter_init(struct hashbidimap_iter *iter, struct hashbidimap *target);
_Bool hbm_iter_start(struct hashbidimap_iter *iter);
_Bool hbm_iter_end(struct hashbidimap_iter *iter);
void hbm_iter_to_start(struct hashbidimap_iter *iter);
void hbm_iter_to_end(struct hashbidimap_iter *iter);
_Bool hbm_iter_next(struct hashbidimap_iter *iter);
_Bool hbm_iter_prev(struct hashbidimap_iter *iter);
_Bool hbm_iter_advance(struct hashbidimap_iter *iter, size_t steps);
_Bool hbm_iter_rewind(struct hashbidimap_iter *iter, size_t steps);
_Bool hbm_iter_go_to(struct hashbidimap_iter *iter, size_t index);
size_t hbm_iter_key(struct hashbidimap_iter *iter);
size_t hbm_iter_value(struct hashbidimap_iter *iter);
size_t hbm_iter_index(struct hashbidimap_iter *iter);
_Bool hbm_to_string(struct hashbidimap *_map_, FILE *fptr);
_Bool hbm_print(struct hashbidimap *_map_, FILE *fptr, const char *start, const char *separator, const char *end,
const char *key_val_sep);
static struct hashbidimap_entry *hbm_impl_new_entry(struct hashbidimap *_map_, size_t key, size_t value);
static struct hashbidimap_entry **hbm_impl_get_entry_by_key(struct hashbidimap *_map_, size_t key);
static struct hashbidimap_entry **hbm_impl_get_entry_by_val(struct hashbidimap *_map_, size_t val);
@@ -949,5 +854,3 @@ _Bool hbm_print(struct hashbidimap *_map_, FILE *fptr, const char *start, const
fprintf(fptr, "%s", end);
return 1;
}
#endif /* CMC_TEST_SRC_HASHBIDIMAP */
@@ -1,100 +1,6 @@
#ifndef CMC_TEST_SRC_HASHMAP
#define CMC_TEST_SRC_HASHMAP
#include "cmc/hashmap.h"
struct hashmap
{
struct hashmap_entry *buffer;
size_t capacity;
size_t count;
double load;
int flag;
struct hashmap_fkey *f_key;
struct hashmap_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct hashmap_entry
{
size_t key;
size_t value;
size_t dist;
enum cmc_entry_state state;
};
struct hashmap_fkey
{
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 hashmap_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 hashmap *hm_new(size_t capacity, double load, struct hashmap_fkey *f_key, struct hashmap_fval *f_val);
struct hashmap *hm_new_custom(size_t capacity, double load, struct hashmap_fkey *f_key, struct hashmap_fval *f_val,
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
void hm_clear(struct hashmap *_map_);
void hm_free(struct hashmap *_map_);
void hm_customize(struct hashmap *_map_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool hm_insert(struct hashmap *_map_, size_t key, size_t value);
_Bool hm_update(struct hashmap *_map_, size_t key, size_t new_value, size_t *old_value);
_Bool hm_remove(struct hashmap *_map_, size_t key, size_t *out_value);
_Bool hm_max(struct hashmap *_map_, size_t *key, size_t *value);
_Bool hm_min(struct hashmap *_map_, size_t *key, size_t *value);
size_t hm_get(struct hashmap *_map_, size_t key);
size_t *hm_get_ref(struct hashmap *_map_, size_t key);
_Bool hm_contains(struct hashmap *_map_, size_t key);
_Bool hm_empty(struct hashmap *_map_);
_Bool hm_full(struct hashmap *_map_);
size_t hm_count(struct hashmap *_map_);
size_t hm_capacity(struct hashmap *_map_);
double hm_load(struct hashmap *_map_);
int hm_flag(struct hashmap *_map_);
_Bool hm_resize(struct hashmap *_map_, size_t capacity);
struct hashmap *hm_copy_of(struct hashmap *_map_);
_Bool hm_equals(struct hashmap *_map1_, struct hashmap *_map2_);
struct hashmap hm_init(size_t capacity, double load, struct hashmap_fkey *f_key, struct hashmap_fval *f_val);
struct hashmap hm_init_custom(size_t capacity, double load, struct hashmap_fkey *f_key, struct hashmap_fval *f_val,
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
void hm_release(struct hashmap _map_);
struct hashmap_iter
{
struct hashmap *target;
size_t cursor;
size_t index;
size_t first;
size_t last;
_Bool start;
_Bool end;
};
struct hashmap_iter hm_iter_start(struct hashmap *target);
struct hashmap_iter hm_iter_end(struct hashmap *target);
_Bool hm_iter_at_start(struct hashmap_iter *iter);
_Bool hm_iter_at_end(struct hashmap_iter *iter);
_Bool hm_iter_to_start(struct hashmap_iter *iter);
_Bool hm_iter_to_end(struct hashmap_iter *iter);
_Bool hm_iter_next(struct hashmap_iter *iter);
_Bool hm_iter_prev(struct hashmap_iter *iter);
_Bool hm_iter_advance(struct hashmap_iter *iter, size_t steps);
_Bool hm_iter_rewind(struct hashmap_iter *iter, size_t steps);
_Bool hm_iter_go_to(struct hashmap_iter *iter, size_t index);
size_t hm_iter_key(struct hashmap_iter *iter);
size_t hm_iter_value(struct hashmap_iter *iter);
size_t *hm_iter_rvalue(struct hashmap_iter *iter);
size_t hm_iter_index(struct hashmap_iter *iter);
_Bool hm_to_string(struct hashmap *_map_, FILE *fptr);
_Bool hm_print(struct hashmap *_map_, FILE *fptr, const char *start, const char *separator, const char *end,
const char *key_val_sep);
static struct hashmap_entry *hm_impl_get_entry(struct hashmap *_map_, size_t key);
static size_t hm_impl_calculate_size(size_t required);
struct hashmap *hm_new(size_t capacity, double load, struct hashmap_fkey *f_key, struct hashmap_fval *f_val)
@@ -884,5 +790,3 @@ _Bool hm_print(struct hashmap *_map_, FILE *fptr, const char *start, const char
fprintf(fptr, "%s", end);
return 1;
}
#endif /* CMC_TEST_SRC_HASHMAP */
@@ -1,102 +1,6 @@
#ifndef CMC_TEST_SRC_HASHMULTIMAP
#define CMC_TEST_SRC_HASHMULTIMAP
#include "cmc/hashmultimap.h"
struct hashmultimap
{
struct hashmultimap_entry *(*buffer)[2];
size_t capacity;
size_t count;
double load;
int flag;
struct hashmultimap_fkey *f_key;
struct hashmultimap_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct hashmultimap_entry
{
size_t key;
size_t value;
struct hashmultimap_entry *next;
struct hashmultimap_entry *prev;
};
struct hashmultimap_fkey
{
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 hashmultimap_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 hashmultimap *hmm_new(size_t capacity, double load, struct hashmultimap_fkey *f_key,
struct hashmultimap_fval *f_val);
struct hashmultimap *hmm_new_custom(size_t capacity, double load, struct hashmultimap_fkey *f_key,
struct hashmultimap_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void hmm_clear(struct hashmultimap *_map_);
void hmm_free(struct hashmultimap *_map_);
void hmm_customize(struct hashmultimap *_map_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool hmm_insert(struct hashmultimap *_map_, size_t key, size_t value);
_Bool hmm_update(struct hashmultimap *_map_, size_t key, size_t new_value, size_t *old_value);
size_t hmm_update_all(struct hashmultimap *_map_, size_t key, size_t new_value, size_t **old_values);
_Bool hmm_remove(struct hashmultimap *_map_, size_t key, size_t *out_value);
size_t hmm_remove_all(struct hashmultimap *_map_, size_t key, size_t **out_values);
_Bool hmm_max(struct hashmultimap *_map_, size_t *key, size_t *value);
_Bool hmm_min(struct hashmultimap *_map_, size_t *key, size_t *value);
size_t hmm_get(struct hashmultimap *_map_, size_t key);
size_t *hmm_get_ref(struct hashmultimap *_map_, size_t key);
_Bool hmm_contains(struct hashmultimap *_map_, size_t key);
_Bool hmm_empty(struct hashmultimap *_map_);
_Bool hmm_full(struct hashmultimap *_map_);
size_t hmm_count(struct hashmultimap *_map_);
size_t hmm_key_count(struct hashmultimap *_map_, size_t key);
size_t hmm_capacity(struct hashmultimap *_map_);
double hmm_load(struct hashmultimap *_map_);
int hmm_flag(struct hashmultimap *_map_);
_Bool hmm_resize(struct hashmultimap *_map_, size_t capacity);
struct hashmultimap *hmm_copy_of(struct hashmultimap *_map_);
_Bool hmm_equals(struct hashmultimap *_map1_, struct hashmultimap *_map2_);
struct hashmultimap_iter
{
struct hashmultimap *target;
struct hashmultimap_entry *curr_entry;
size_t cursor;
size_t index;
size_t first;
size_t last;
_Bool start;
_Bool end;
};
struct hashmultimap_iter hmm_iter_start(struct hashmultimap *target);
struct hashmultimap_iter hmm_iter_end(struct hashmultimap *target);
_Bool hmm_iter_at_start(struct hashmultimap_iter *iter);
_Bool hmm_iter_at_end(struct hashmultimap_iter *iter);
_Bool hmm_iter_to_start(struct hashmultimap_iter *iter);
_Bool hmm_iter_to_end(struct hashmultimap_iter *iter);
_Bool hmm_iter_next(struct hashmultimap_iter *iter);
_Bool hmm_iter_prev(struct hashmultimap_iter *iter);
_Bool hmm_iter_advance(struct hashmultimap_iter *iter, size_t steps);
_Bool hmm_iter_rewind(struct hashmultimap_iter *iter, size_t steps);
_Bool hmm_iter_go_to(struct hashmultimap_iter *iter, size_t index);
size_t hmm_iter_key(struct hashmultimap_iter *iter);
size_t hmm_iter_value(struct hashmultimap_iter *iter);
size_t *hmm_iter_rvalue(struct hashmultimap_iter *iter);
size_t hmm_iter_index(struct hashmultimap_iter *iter);
_Bool hmm_to_string(struct hashmultimap *_map_, FILE *fptr);
_Bool hmm_print(struct hashmultimap *_map_, FILE *fptr, const char *start, const char *separator, const char *end,
const char *key_val_sep);
struct hashmultimap_entry *hmm_impl_new_entry(struct hashmultimap *_map_, size_t key, size_t value);
struct hashmultimap_entry *hmm_impl_get_entry(struct hashmultimap *_map_, size_t key);
size_t hmm_impl_key_count(struct hashmultimap *_map_, size_t key);
@@ -1005,5 +909,3 @@ _Bool hmm_print(struct hashmultimap *_map_, FILE *fptr, const char *start, const
fprintf(fptr, "%s", end);
return 1;
}
#endif /* CMC_TEST_SRC_HASHMULTIMAP */
@@ -1,98 +1,6 @@
#ifndef CMC_TEST_SRC_HASHMULTISET
#define CMC_TEST_SRC_HASHMULTISET
#include "cmc/hashmultiset.h"
struct hashmultiset
{
struct hashmultiset_entry *buffer;
size_t capacity;
size_t count;
size_t cardinality;
double load;
int flag;
struct hashmultiset_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct hashmultiset_entry
{
size_t value;
size_t multiplicity;
size_t dist;
enum cmc_entry_state state;
};
struct hashmultiset_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 hashmultiset *hms_new(size_t capacity, double load, struct hashmultiset_fval *f_val);
struct hashmultiset *hms_new_custom(size_t capacity, double load, struct hashmultiset_fval *f_val,
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
void hms_clear(struct hashmultiset *_set_);
void hms_free(struct hashmultiset *_set_);
void hms_customize(struct hashmultiset *_set_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool hms_insert(struct hashmultiset *_set_, size_t value);
_Bool hms_insert_many(struct hashmultiset *_set_, size_t value, size_t count);
_Bool hms_update(struct hashmultiset *_set_, size_t value, size_t multiplicity);
_Bool hms_remove(struct hashmultiset *_set_, size_t value);
size_t hms_remove_all(struct hashmultiset *_set_, size_t value);
_Bool hms_max(struct hashmultiset *_set_, size_t *value);
_Bool hms_min(struct hashmultiset *_set_, size_t *value);
size_t hms_multiplicity_of(struct hashmultiset *_set_, size_t value);
_Bool hms_contains(struct hashmultiset *_set_, size_t value);
_Bool hms_empty(struct hashmultiset *_set_);
_Bool hms_full(struct hashmultiset *_set_);
size_t hms_count(struct hashmultiset *_set_);
size_t hms_cardinality(struct hashmultiset *_set_);
size_t hms_capacity(struct hashmultiset *_set_);
double hms_load(struct hashmultiset *_set_);
int hms_flag(struct hashmultiset *_set_);
_Bool hms_resize(struct hashmultiset *_set_, size_t capacity);
struct hashmultiset *hms_copy_of(struct hashmultiset *_set_);
_Bool hms_equals(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
struct hashmultiset_iter
{
struct hashmultiset *target;
size_t cursor;
size_t index;
size_t first;
size_t last;
_Bool start;
_Bool end;
};
struct hashmultiset_iter hms_iter_start(struct hashmultiset *target);
struct hashmultiset_iter hms_iter_end(struct hashmultiset *target);
_Bool hms_iter_at_start(struct hashmultiset_iter *iter);
_Bool hms_iter_at_end(struct hashmultiset_iter *iter);
_Bool hms_iter_to_start(struct hashmultiset_iter *iter);
_Bool hms_iter_to_end(struct hashmultiset_iter *iter);
_Bool hms_iter_next(struct hashmultiset_iter *iter);
_Bool hms_iter_prev(struct hashmultiset_iter *iter);
_Bool hms_iter_advance(struct hashmultiset_iter *iter, size_t steps);
_Bool hms_iter_rewind(struct hashmultiset_iter *iter, size_t steps);
_Bool hms_iter_go_to(struct hashmultiset_iter *iter, size_t index);
size_t hms_iter_value(struct hashmultiset_iter *iter);
size_t hms_iter_multiplicity(struct hashmultiset_iter *iter);
size_t hms_iter_index(struct hashmultiset_iter *iter);
struct hashmultiset *hms_union(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
struct hashmultiset *hms_intersection(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
struct hashmultiset *hms_difference(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
struct hashmultiset *hms_summation(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
struct hashmultiset *hms_symmetric_difference(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
_Bool hms_is_subset(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
_Bool hms_is_superset(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
_Bool hms_is_proper_subset(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
_Bool hms_is_proper_superset(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
_Bool hms_is_disjointset(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
_Bool hms_to_string(struct hashmultiset *_set_, FILE *fptr);
_Bool hms_print(struct hashmultiset *_set_, FILE *fptr, const char *start, const char *separator, const char *end,
const char *key_val_sep);
static size_t hms_impl_multiplicity_of(struct hashmultiset *_set_, size_t value);
static struct hashmultiset_entry *hms_impl_insert_and_return(struct hashmultiset *_set_, size_t value, _Bool *new_node);
static struct hashmultiset_entry *hms_impl_get_entry(struct hashmultiset *_set_, size_t value);
@@ -1036,5 +944,3 @@ _Bool hms_print(struct hashmultiset *_set_, FILE *fptr, const char *start, const
fprintf(fptr, "%s", end);
return 1;
}
#endif /* CMC_TEST_SRC_HASHMULTISET */
@@ -1,88 +1,6 @@
#ifndef CMC_TEST_SRC_HASHSET
#define CMC_TEST_SRC_HASHSET
#include "cmc/hashset.h"
struct hashset
{
struct hashset_entry *buffer;
size_t capacity;
size_t count;
double load;
int flag;
struct hashset_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct hashset_entry
{
size_t value;
size_t dist;
enum cmc_entry_state state;
};
struct hashset_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 hashset *hs_new(size_t capacity, double load, struct hashset_fval *f_val);
struct hashset *hs_new_custom(size_t capacity, double load, struct hashset_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void hs_clear(struct hashset *_set_);
void hs_free(struct hashset *_set_);
void hs_customize(struct hashset *_set_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool hs_insert(struct hashset *_set_, size_t value);
_Bool hs_remove(struct hashset *_set_, size_t value);
_Bool hs_max(struct hashset *_set_, size_t *value);
_Bool hs_min(struct hashset *_set_, size_t *value);
_Bool hs_contains(struct hashset *_set_, size_t value);
_Bool hs_empty(struct hashset *_set_);
_Bool hs_full(struct hashset *_set_);
size_t hs_count(struct hashset *_set_);
size_t hs_capacity(struct hashset *_set_);
double hs_load(struct hashset *_set_);
int hs_flag(struct hashset *_set_);
_Bool hs_resize(struct hashset *_set_, size_t capacity);
struct hashset *hs_copy_of(struct hashset *_set_);
_Bool hs_equals(struct hashset *_set1_, struct hashset *_set2_);
struct hashset_iter
{
struct hashset *target;
size_t cursor;
size_t index;
size_t first;
size_t last;
_Bool start;
_Bool end;
};
struct hashset_iter hs_iter_start(struct hashset *target);
struct hashset_iter hs_iter_end(struct hashset *target);
_Bool hs_iter_at_start(struct hashset_iter *iter);
_Bool hs_iter_at_end(struct hashset_iter *iter);
_Bool hs_iter_to_start(struct hashset_iter *iter);
_Bool hs_iter_to_end(struct hashset_iter *iter);
_Bool hs_iter_next(struct hashset_iter *iter);
_Bool hs_iter_prev(struct hashset_iter *iter);
_Bool hs_iter_advance(struct hashset_iter *iter, size_t steps);
_Bool hs_iter_rewind(struct hashset_iter *iter, size_t steps);
_Bool hs_iter_go_to(struct hashset_iter *iter, size_t index);
size_t hs_iter_value(struct hashset_iter *iter);
size_t hs_iter_index(struct hashset_iter *iter);
struct hashset *hs_union(struct hashset *_set1_, struct hashset *_set2_);
struct hashset *hs_intersection(struct hashset *_set1_, struct hashset *_set2_);
struct hashset *hs_difference(struct hashset *_set1_, struct hashset *_set2_);
struct hashset *hs_symmetric_difference(struct hashset *_set1_, struct hashset *_set2_);
_Bool hs_is_subset(struct hashset *_set1_, struct hashset *_set2_);
_Bool hs_is_superset(struct hashset *_set1_, struct hashset *_set2_);
_Bool hs_is_proper_subset(struct hashset *_set1_, struct hashset *_set2_);
_Bool hs_is_proper_superset(struct hashset *_set1_, struct hashset *_set2_);
_Bool hs_is_disjointset(struct hashset *_set1_, struct hashset *_set2_);
_Bool hs_to_string(struct hashset *_set_, FILE *fptr);
_Bool hs_print(struct hashset *_set_, FILE *fptr, const char *start, const char *separator, const char *end);
static struct hashset_entry *hs_impl_get_entry(struct hashset *_set_, size_t value);
static size_t hs_impl_calculate_size(size_t required);
struct hashset *hs_new(size_t capacity, double load, struct hashset_fval *f_val)
@@ -835,5 +753,3 @@ _Bool hs_print(struct hashset *_set_, FILE *fptr, const char *start, const char
fprintf(fptr, "%s", end);
return 1;
}
#endif /* CMC_TEST_SRC_HASHSET */
@@ -1,68 +1,6 @@
#ifndef CMC_TEST_SRC_HEAP
#define CMC_TEST_SRC_HEAP
#include "cmc/heap.h"
struct heap
{
size_t *buffer;
size_t capacity;
size_t count;
enum cmc_heap_order HO;
int flag;
struct heap_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct heap_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 heap *h_new(size_t capacity, enum cmc_heap_order HO, struct heap_fval *f_val);
struct heap *h_new_custom(size_t capacity, enum cmc_heap_order HO, struct heap_fval *f_val,
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
void h_clear(struct heap *_heap_);
void h_free(struct heap *_heap_);
void h_customize(struct heap *_heap_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool h_insert(struct heap *_heap_, size_t value);
_Bool h_remove(struct heap *_heap_);
size_t h_peek(struct heap *_heap_);
_Bool h_contains(struct heap *_heap_, size_t value);
_Bool h_empty(struct heap *_heap_);
_Bool h_full(struct heap *_heap_);
size_t h_count(struct heap *_heap_);
size_t h_capacity(struct heap *_heap_);
int h_flag(struct heap *_heap_);
_Bool h_resize(struct heap *_heap_, size_t capacity);
struct heap *h_copy_of(struct heap *_heap_);
_Bool h_equals(struct heap *_heap1_, struct heap *_heap2_);
struct heap_iter
{
struct heap *target;
size_t cursor;
_Bool start;
_Bool end;
};
struct heap_iter h_iter_start(struct heap *target);
struct heap_iter h_iter_end(struct heap *target);
_Bool h_iter_at_start(struct heap_iter *iter);
_Bool h_iter_at_end(struct heap_iter *iter);
_Bool h_iter_to_start(struct heap_iter *iter);
_Bool h_iter_to_end(struct heap_iter *iter);
_Bool h_iter_next(struct heap_iter *iter);
_Bool h_iter_prev(struct heap_iter *iter);
_Bool h_iter_advance(struct heap_iter *iter, size_t steps);
_Bool h_iter_rewind(struct heap_iter *iter, size_t steps);
_Bool h_iter_go_to(struct heap_iter *iter, size_t index);
size_t h_iter_value(struct heap_iter *iter);
size_t h_iter_index(struct heap_iter *iter);
_Bool h_to_string(struct heap *_heap_, FILE *fptr);
_Bool h_print(struct heap *_heap_, FILE *fptr, const char *start, const char *separator, const char *end);
static void h_impl_float_up(struct heap *_heap_, size_t index);
static void h_impl_float_down(struct heap *_heap_, size_t index);
struct heap *h_new(size_t capacity, enum cmc_heap_order HO, struct heap_fval *f_val)
@@ -484,5 +422,3 @@ _Bool h_print(struct heap *_heap_, FILE *fptr, const char *start, const char *se
fprintf(fptr, "%s", end);
return 1;
}
#endif /* CMC_TEST_SRC_HEAP */
@@ -1,72 +1,6 @@
#ifndef CMC_TEST_SRC_INTERVALHEAP
#define CMC_TEST_SRC_INTERVALHEAP
#include "cmc/intervalheap.h"
struct intervalheap
{
size_t (*buffer)[2];
size_t capacity;
size_t size;
size_t count;
int flag;
struct intervalheap_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct intervalheap_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 intervalheap *ih_new(size_t capacity, struct intervalheap_fval *f_val);
struct intervalheap *ih_new_custom(size_t capacity, struct intervalheap_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void ih_clear(struct intervalheap *_heap_);
void ih_free(struct intervalheap *_heap_);
void ih_customize(struct intervalheap *_heap_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool ih_insert(struct intervalheap *_heap_, size_t value);
_Bool ih_remove_max(struct intervalheap *_heap_);
_Bool ih_remove_min(struct intervalheap *_heap_);
_Bool ih_update_max(struct intervalheap *_heap_, size_t value);
_Bool ih_update_min(struct intervalheap *_heap_, size_t value);
size_t ih_max(struct intervalheap *_heap_);
size_t ih_min(struct intervalheap *_heap_);
_Bool ih_contains(struct intervalheap *_heap_, size_t value);
_Bool ih_empty(struct intervalheap *_heap_);
_Bool ih_full(struct intervalheap *_heap_);
size_t ih_count(struct intervalheap *_heap_);
size_t ih_capacity(struct intervalheap *_heap_);
int ih_flag(struct intervalheap *_heap_);
_Bool ih_resize(struct intervalheap *_heap_, size_t capacity);
struct intervalheap *ih_copy_of(struct intervalheap *_heap_);
_Bool ih_equals(struct intervalheap *_heap1_, struct intervalheap *_heap2_);
struct intervalheap_iter
{
struct intervalheap *target;
size_t cursor;
_Bool start;
_Bool end;
};
struct intervalheap_iter ih_iter_start(struct intervalheap *target);
struct intervalheap_iter ih_iter_end(struct intervalheap *target);
_Bool ih_iter_at_start(struct intervalheap_iter *iter);
_Bool ih_iter_at_end(struct intervalheap_iter *iter);
_Bool ih_iter_to_start(struct intervalheap_iter *iter);
_Bool ih_iter_to_end(struct intervalheap_iter *iter);
_Bool ih_iter_next(struct intervalheap_iter *iter);
_Bool ih_iter_prev(struct intervalheap_iter *iter);
_Bool ih_iter_advance(struct intervalheap_iter *iter, size_t steps);
_Bool ih_iter_rewind(struct intervalheap_iter *iter, size_t steps);
_Bool ih_iter_go_to(struct intervalheap_iter *iter, size_t index);
size_t ih_iter_value(struct intervalheap_iter *iter);
size_t ih_iter_index(struct intervalheap_iter *iter);
_Bool ih_to_string(struct intervalheap *_heap_, FILE *fptr);
_Bool ih_print(struct intervalheap *_heap_, FILE *fptr, const char *start, const char *separator, const char *end);
static void ih_impl_float_up_max(struct intervalheap *_heap_);
static void ih_impl_float_up_min(struct intervalheap *_heap_);
static void ih_impl_float_down_max(struct intervalheap *_heap_);
@@ -750,5 +684,3 @@ _Bool ih_print(struct intervalheap *_heap_, FILE *fptr, const char *start, const
fprintf(fptr, "%s", end);
return 1;
}
#endif /* CMC_TEST_SRC_INTERVALHEAP */
@@ -1,92 +1,6 @@
#ifndef CMC_TEST_SRC_LINKEDLIST
#define CMC_TEST_SRC_LINKEDLIST
#include "cmc/linkedlist.h"
struct linkedlist
{
struct linkedlist_node *head;
struct linkedlist_node *tail;
size_t count;
int flag;
struct linkedlist_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct linkedlist_node
{
size_t value;
struct linkedlist_node *next;
struct linkedlist_node *prev;
};
struct linkedlist_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 linkedlist *ll_new(struct linkedlist_fval *f_val);
struct linkedlist *ll_new_custom(struct linkedlist_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void ll_clear(struct linkedlist *_list_);
void ll_free(struct linkedlist *_list_);
void ll_customize(struct linkedlist *_list_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool ll_push_front(struct linkedlist *_list_, size_t value);
_Bool ll_push_at(struct linkedlist *_list_, size_t value, size_t index);
_Bool ll_push_back(struct linkedlist *_list_, size_t value);
_Bool ll_pop_front(struct linkedlist *_list_);
_Bool ll_pop_at(struct linkedlist *_list_, size_t index);
_Bool ll_pop_back(struct linkedlist *_list_);
size_t ll_front(struct linkedlist *_list_);
size_t ll_get(struct linkedlist *_list_, size_t index);
size_t *ll_get_ref(struct linkedlist *_list_, size_t index);
size_t ll_back(struct linkedlist *_list_);
_Bool ll_contains(struct linkedlist *_list_, size_t value);
_Bool ll_empty(struct linkedlist *_list_);
size_t ll_count(struct linkedlist *_list_);
int ll_flag(struct linkedlist *_list_);
struct linkedlist *ll_copy_of(struct linkedlist *_list_);
_Bool ll_equals(struct linkedlist *_list1_, struct linkedlist *_list2_);
struct linkedlist_iter
{
struct linkedlist *target;
struct linkedlist_node *cursor;
size_t index;
_Bool start;
_Bool end;
};
struct linkedlist_iter ll_iter_start(struct linkedlist *target);
struct linkedlist_iter ll_iter_end(struct linkedlist *target);
_Bool ll_iter_at_start(struct linkedlist_iter *iter);
_Bool ll_iter_at_end(struct linkedlist_iter *iter);
_Bool ll_iter_to_start(struct linkedlist_iter *iter);
_Bool ll_iter_to_end(struct linkedlist_iter *iter);
_Bool ll_iter_next(struct linkedlist_iter *iter);
_Bool ll_iter_prev(struct linkedlist_iter *iter);
_Bool ll_iter_advance(struct linkedlist_iter *iter, size_t steps);
_Bool ll_iter_rewind(struct linkedlist_iter *iter, size_t steps);
_Bool ll_iter_go_to(struct linkedlist_iter *iter, size_t index);
size_t ll_iter_value(struct linkedlist_iter *iter);
size_t *ll_iter_rvalue(struct linkedlist_iter *iter);
size_t ll_iter_index(struct linkedlist_iter *iter);
struct linkedlist_node *ll_iter_node(struct linkedlist_iter *iter);
struct linkedlist_node *ll_new_node(struct linkedlist *_list_, size_t value);
void ll_free_node(struct linkedlist *_list_, struct linkedlist_node *_node_);
struct linkedlist_node *ll_head(struct linkedlist *_list_);
struct linkedlist_node *ll_get_node(struct linkedlist *_list_, size_t index);
struct linkedlist_node *ll_tail(struct linkedlist *_list_);
_Bool ll_add_next(struct linkedlist *_owner_, struct linkedlist_node *_node_, size_t value);
_Bool ll_add_prev(struct linkedlist *_owner_, struct linkedlist_node *_node_, size_t value);
_Bool ll_del_next(struct linkedlist *_owner_, struct linkedlist_node *_node_);
_Bool ll_del_curr(struct linkedlist *_owner_, struct linkedlist_node *_node_);
_Bool ll_del_prev(struct linkedlist *_owner_, struct linkedlist_node *_node_);
struct linkedlist_node *ll_next_node(struct linkedlist_node *_node_);
struct linkedlist_node *ll_prev_node(struct linkedlist_node *_node_);
_Bool ll_to_string(struct linkedlist *_list_, FILE *fptr);
_Bool ll_print(struct linkedlist *_list_, FILE *fptr, const char *start, const char *separator, const char *end);
struct linkedlist *ll_new(struct linkedlist_fval *f_val)
{
return ll_new_custom(f_val, ((void *)0), ((void *)0));
@@ -767,5 +681,3 @@ _Bool ll_print(struct linkedlist *_list_, FILE *fptr, const char *start, const c
fprintf(fptr, "%s", end);
return 1;
}
#endif /* CMC_TEST_SRC_LINKEDLIST */
@@ -1,82 +1,6 @@
#ifndef CMC_TEST_SRC_LIST
#define CMC_TEST_SRC_LIST
#include "cmc/list.h"
struct list
{
size_t *buffer;
size_t capacity;
size_t count;
int flag;
struct list_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct list_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 list *l_new(size_t capacity, struct list_fval *f_val);
struct list *l_new_custom(size_t capacity, struct list_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void l_clear(struct list *_list_);
void l_free(struct list *_list_);
void l_customize(struct list *_list_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool l_push_front(struct list *_list_, size_t value);
_Bool l_push_at(struct list *_list_, size_t value, size_t index);
_Bool l_push_back(struct list *_list_, size_t value);
_Bool l_pop_front(struct list *_list_);
_Bool l_pop_at(struct list *_list_, size_t index);
_Bool l_pop_back(struct list *_list_);
size_t l_front(struct list *_list_);
size_t l_get(struct list *_list_, size_t index);
size_t *l_get_ref(struct list *_list_, size_t index);
size_t l_back(struct list *_list_);
size_t l_index_of(struct list *_list_, size_t value, _Bool from_start);
_Bool l_contains(struct list *_list_, size_t value);
_Bool l_empty(struct list *_list_);
_Bool l_full(struct list *_list_);
size_t l_count(struct list *_list_);
_Bool l_fits(struct list *_list_, size_t size);
size_t l_capacity(struct list *_list_);
int l_flag(struct list *_list_);
_Bool l_resize(struct list *_list_, size_t capacity);
struct list *l_copy_of(struct list *_list_);
_Bool l_equals(struct list *_list1_, struct list *_list2_);
struct list_iter
{
struct list *target;
size_t cursor;
_Bool start;
_Bool end;
};
struct list_iter l_iter_start(struct list *target);
struct list_iter l_iter_end(struct list *target);
_Bool l_iter_at_start(struct list_iter *iter);
_Bool l_iter_at_end(struct list_iter *iter);
_Bool l_iter_to_start(struct list_iter *iter);
_Bool l_iter_to_end(struct list_iter *iter);
_Bool l_iter_next(struct list_iter *iter);
_Bool l_iter_prev(struct list_iter *iter);
_Bool l_iter_advance(struct list_iter *iter, size_t steps);
_Bool l_iter_rewind(struct list_iter *iter, size_t steps);
_Bool l_iter_go_to(struct list_iter *iter, size_t index);
size_t l_iter_value(struct list_iter *iter);
size_t *l_iter_rvalue(struct list_iter *iter);
size_t l_iter_index(struct list_iter *iter);
_Bool l_seq_push_front(struct list *_list_, size_t *values, size_t size);
_Bool l_seq_push_at(struct list *_list_, size_t *values, size_t size, size_t index);
_Bool l_seq_push_back(struct list *_list_, size_t *values, size_t size);
_Bool l_seq_pop_at(struct list *_list_, size_t from, size_t to);
struct list *l_seq_sublist(struct list *_list_, size_t from, size_t to);
_Bool l_to_string(struct list *_list_, FILE *fptr);
_Bool l_print(struct list *_list_, FILE *fptr, const char *start, const char *separator, const char *end);
struct list *l_new(size_t capacity, struct list_fval *f_val)
{
return l_new_custom(capacity, f_val, ((void *)0), ((void *)0));
@@ -717,5 +641,3 @@ _Bool l_print(struct list *_list_, FILE *fptr, const char *start, const char *se
fprintf(fptr, "%s", end);
return 1;
}
#endif /* CMC_TEST_SRC_LIST */
@@ -1,71 +1,6 @@
#ifndef CMC_TEST_SRC_QUEUE
#define CMC_TEST_SRC_QUEUE
#include "cmc/queue.h"
struct queue
{
size_t *buffer;
size_t capacity;
size_t count;
size_t front;
size_t back;
int flag;
struct queue_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct queue_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 queue_iter
{
struct queue *target;
size_t cursor;
size_t index;
_Bool start;
_Bool end;
};
struct queue *q_new(size_t capacity, struct queue_fval *f_val);
struct queue *q_new_custom(size_t capacity, struct queue_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void q_clear(struct queue *_queue_);
void q_free(struct queue *_queue_);
void q_customize(struct queue *_queue_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool q_enqueue(struct queue *_queue_, size_t value);
_Bool q_dequeue(struct queue *_queue_);
size_t q_peek(struct queue *_queue_);
_Bool q_contains(struct queue *_queue_, size_t value);
_Bool q_empty(struct queue *_queue_);
_Bool q_full(struct queue *_queue_);
size_t q_count(struct queue *_queue_);
size_t q_capacity(struct queue *_queue_);
int q_flag(struct queue *_queue_);
_Bool q_resize(struct queue *_queue_, size_t capacity);
struct queue *q_copy_of(struct queue *_queue_);
_Bool q_equals(struct queue *_queue1_, struct queue *_queue2_);
struct queue_iter q_iter_start(struct queue *target);
struct queue_iter q_iter_end(struct queue *target);
_Bool q_iter_at_start(struct queue_iter *iter);
_Bool q_iter_at_end(struct queue_iter *iter);
_Bool q_iter_to_start(struct queue_iter *iter);
_Bool q_iter_to_end(struct queue_iter *iter);
_Bool q_iter_next(struct queue_iter *iter);
_Bool q_iter_prev(struct queue_iter *iter);
_Bool q_iter_advance(struct queue_iter *iter, size_t steps);
_Bool q_iter_rewind(struct queue_iter *iter, size_t steps);
_Bool q_iter_go_to(struct queue_iter *iter, size_t index);
size_t q_iter_value(struct queue_iter *iter);
size_t *q_iter_rvalue(struct queue_iter *iter);
size_t q_iter_index(struct queue_iter *iter);
_Bool q_to_string(struct queue *_queue_, FILE *fptr);
_Bool q_print(struct queue *_queue_, FILE *fptr, const char *start, const char *separator, const char *end);
struct queue *q_new(size_t capacity, struct queue_fval *f_val)
{
return q_new_custom(capacity, f_val, ((void *)0), ((void *)0));
@@ -494,5 +429,3 @@ _Bool q_print(struct queue *_queue_, FILE *fptr, const char *start, const char *
fprintf(fptr, "%s", end);
return 1;
}
#endif /* CMC_TEST_SRC_QUEUE */
@@ -1,72 +1,6 @@
#ifndef CMC_TEST_SRC_SORTEDLIST
#define CMC_TEST_SRC_SORTEDLIST
#include "cmc/sortedlist.h"
struct sortedlist
{
size_t *buffer;
size_t capacity;
size_t count;
_Bool is_sorted;
int flag;
struct sortedlist_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct sortedlist_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 sortedlist *sl_new(size_t capacity, struct sortedlist_fval *f_val);
struct sortedlist *sl_new_custom(size_t capacity, struct sortedlist_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void sl_clear(struct sortedlist *_list_);
void sl_free(struct sortedlist *_list_);
void sl_customize(struct sortedlist *_list_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool sl_insert(struct sortedlist *_list_, size_t value);
_Bool sl_remove(struct sortedlist *_list_, size_t index);
size_t sl_max(struct sortedlist *_list_);
size_t sl_min(struct sortedlist *_list_);
size_t sl_get(struct sortedlist *_list_, size_t index);
size_t sl_index_of(struct sortedlist *_list_, size_t value, _Bool from_start);
_Bool sl_contains(struct sortedlist *_list_, size_t value);
_Bool sl_empty(struct sortedlist *_list_);
_Bool sl_full(struct sortedlist *_list_);
size_t sl_count(struct sortedlist *_list_);
size_t sl_capacity(struct sortedlist *_list_);
int sl_flag(struct sortedlist *_list_);
_Bool sl_resize(struct sortedlist *_list_, size_t capacity);
void sl_sort(struct sortedlist *_list_);
struct sortedlist *sl_copy_of(struct sortedlist *_list_);
_Bool sl_equals(struct sortedlist *_list1_, struct sortedlist *_list2_);
struct sortedlist_iter
{
struct sortedlist *target;
size_t cursor;
_Bool start;
_Bool end;
};
struct sortedlist_iter sl_iter_start(struct sortedlist *target);
struct sortedlist_iter sl_iter_end(struct sortedlist *target);
_Bool sl_iter_at_start(struct sortedlist_iter *iter);
_Bool sl_iter_at_end(struct sortedlist_iter *iter);
_Bool sl_iter_to_start(struct sortedlist_iter *iter);
_Bool sl_iter_to_end(struct sortedlist_iter *iter);
_Bool sl_iter_next(struct sortedlist_iter *iter);
_Bool sl_iter_prev(struct sortedlist_iter *iter);
_Bool sl_iter_advance(struct sortedlist_iter *iter, size_t steps);
_Bool sl_iter_rewind(struct sortedlist_iter *iter, size_t steps);
_Bool sl_iter_go_to(struct sortedlist_iter *iter, size_t index);
size_t sl_iter_value(struct sortedlist_iter *iter);
size_t sl_iter_index(struct sortedlist_iter *iter);
_Bool sl_to_string(struct sortedlist *_list_, FILE *fptr);
_Bool sl_print(struct sortedlist *_list_, FILE *fptr, const char *start, const char *separator, const char *end);
static size_t sl_impl_binary_search_first(struct sortedlist *_list_, size_t value);
static size_t sl_impl_binary_search_last(struct sortedlist *_list_, size_t value);
void sl_impl_sort_quicksort(size_t *array, int (*cmp)(size_t, size_t), size_t low, size_t high);
@@ -576,5 +510,3 @@ _Bool sl_print(struct sortedlist *_list_, FILE *fptr, const char *start, const c
fprintf(fptr, "%s", end);
return 1;
}
#endif /* CMC_TEST_SRC_SORTEDLIST */
@@ -1,68 +1,6 @@
#ifndef CMC_TEST_SRC_STACK
#define CMC_TEST_SRC_STACK
#include "cmc/stack.h"
struct stack
{
size_t *buffer;
size_t capacity;
size_t count;
int flag;
struct stack_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct stack_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 stack *s_new(size_t capacity, struct stack_fval *f_val);
struct stack *s_new_custom(size_t capacity, struct stack_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void s_clear(struct stack *_stack_);
void s_free(struct stack *_stack_);
void s_customize(struct stack *_stack_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool s_push(struct stack *_stack_, size_t value);
_Bool s_pop(struct stack *_stack_);
size_t s_top(struct stack *_stack_);
_Bool s_contains(struct stack *_stack_, size_t value);
_Bool s_empty(struct stack *_stack_);
_Bool s_full(struct stack *_stack_);
size_t s_count(struct stack *_stack_);
size_t s_capacity(struct stack *_stack_);
int s_flag(struct stack *_stack_);
_Bool s_resize(struct stack *_stack_, size_t capacity);
struct stack *s_copy_of(struct stack *_stack_);
_Bool s_equals(struct stack *_stack1_, struct stack *_stack2_);
struct stack_iter
{
struct stack *target;
size_t cursor;
_Bool start;
_Bool end;
};
struct stack_iter s_iter_start(struct stack *target);
struct stack_iter s_iter_end(struct stack *target);
_Bool s_iter_at_start(struct stack_iter *iter);
_Bool s_iter_at_end(struct stack_iter *iter);
_Bool s_iter_to_start(struct stack_iter *iter);
_Bool s_iter_to_end(struct stack_iter *iter);
_Bool s_iter_next(struct stack_iter *iter);
_Bool s_iter_prev(struct stack_iter *iter);
_Bool s_iter_advance(struct stack_iter *iter, size_t steps);
_Bool s_iter_rewind(struct stack_iter *iter, size_t steps);
_Bool s_iter_go_to(struct stack_iter *iter, size_t index);
size_t s_iter_value(struct stack_iter *iter);
size_t *s_iter_rvalue(struct stack_iter *iter);
size_t s_iter_index(struct stack_iter *iter);
_Bool s_to_string(struct stack *_stack_, FILE *fptr);
_Bool s_print(struct stack *_stack_, FILE *fptr, const char *start, const char *separator, const char *end);
struct stack *s_new(size_t capacity, struct stack_fval *f_val)
{
return s_new_custom(capacity, f_val, ((void *)0), ((void *)0));
@@ -235,7 +173,7 @@ struct stack *s_copy_of(struct stack *_stack_)
_stack_->flag = CMC_FLAG_ERROR;
return ((void *)0);
}
(_stack_)->callbacks = callbacks;
(result)->callbacks = _stack_->callbacks;
if (_stack_->f_val->cpy)
{
for (size_t i = 0; i < _stack_->count; i++)
@@ -427,5 +365,3 @@ _Bool s_print(struct stack *_stack_, FILE *fptr, const char *start, const char *
fprintf(fptr, "%s", end);
return 1;
}
#endif /* CMC_TEST_SRC_STACK */
@@ -1,92 +1,6 @@
#ifndef CMC_TEST_SRC_TREEMAP
#define CMC_TEST_SRC_TREEMAP
#include "cmc/treemap.h"
struct treemap
{
struct treemap_node *root;
size_t count;
int flag;
struct treemap_fkey *f_key;
struct treemap_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct treemap_node
{
size_t key;
size_t value;
unsigned char height;
struct treemap_node *right;
struct treemap_node *left;
struct treemap_node *parent;
};
struct treemap_fkey
{
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 treemap_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 treemap *tm_new(struct treemap_fkey *f_key, struct treemap_fval *f_val);
struct treemap *tm_new_custom(struct treemap_fkey *f_key, struct treemap_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void tm_clear(struct treemap *_map_);
void tm_free(struct treemap *_map_);
void tm_customize(struct treemap *_map_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool tm_insert(struct treemap *_map_, size_t key, size_t value);
_Bool tm_update(struct treemap *_map_, size_t key, size_t new_value, size_t *old_value);
_Bool tm_remove(struct treemap *_map_, size_t key, size_t *out_value);
_Bool tm_max(struct treemap *_map_, size_t *key, size_t *value);
_Bool tm_min(struct treemap *_map_, size_t *key, size_t *value);
size_t tm_get(struct treemap *_map_, size_t key);
size_t *tm_get_ref(struct treemap *_map_, size_t key);
_Bool tm_contains(struct treemap *_map_, size_t key);
_Bool tm_empty(struct treemap *_map_);
size_t tm_count(struct treemap *_map_);
int tm_flag(struct treemap *_map_);
struct treemap *tm_copy_of(struct treemap *_map_);
_Bool tm_equals(struct treemap *_map1_, struct treemap *_map2_);
struct treemap_iter
{
struct treemap *target;
struct treemap_node *cursor;
struct treemap_node *first;
struct treemap_node *last;
size_t index;
_Bool start;
_Bool end;
};
struct treemap_iter tm_iter_start(struct treemap *target);
struct treemap_iter tm_iter_end(struct treemap *target);
_Bool tm_iter_at_start(struct treemap_iter *iter);
_Bool tm_iter_at_end(struct treemap_iter *iter);
_Bool tm_iter_to_start(struct treemap_iter *iter);
_Bool tm_iter_to_end(struct treemap_iter *iter);
_Bool tm_iter_next(struct treemap_iter *iter);
_Bool tm_iter_prev(struct treemap_iter *iter);
_Bool tm_iter_advance(struct treemap_iter *iter, size_t steps);
_Bool tm_iter_rewind(struct treemap_iter *iter, size_t steps);
_Bool tm_iter_go_to(struct treemap_iter *iter, size_t index);
size_t tm_iter_key(struct treemap_iter *iter);
size_t tm_iter_value(struct treemap_iter *iter);
size_t *tm_iter_rvalue(struct treemap_iter *iter);
size_t tm_iter_index(struct treemap_iter *iter);
_Bool tm_to_string(struct treemap *_map_, FILE *fptr);
_Bool tm_print(struct treemap *_map_, FILE *fptr, const char *start, const char *separator, const char *end,
const char *key_val_sep);
static struct treemap_node *tm_impl_new_node(struct treemap *_map_, size_t key, size_t value);
static struct treemap_node *tm_impl_get_node(struct treemap *_map_, size_t key);
static unsigned char tm_impl_h(struct treemap_node *node);
@@ -888,5 +802,3 @@ _Bool tm_print(struct treemap *_map_, FILE *fptr, const char *start, const char
fprintf(fptr, "%s", end);
return 1;
}
#endif /* CMC_TEST_SRC_TREEMAP */
@@ -1,84 +1,6 @@
#ifndef CMC_TEST_SRC_TREESET
#define CMC_TEST_SRC_TREESET
#include "cmc/treeset.h"
struct treeset
{
struct treeset_node *root;
size_t count;
int flag;
struct treeset_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct treeset_node
{
size_t value;
unsigned char height;
struct treeset_node *right;
struct treeset_node *left;
struct treeset_node *parent;
};
struct treeset_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 treeset_iter
{
struct treeset *target;
struct treeset_node *cursor;
struct treeset_node *first;
struct treeset_node *last;
size_t index;
_Bool start;
_Bool end;
};
struct treeset *ts_new(struct treeset_fval *f_val);
struct treeset *ts_new_custom(struct treeset_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void ts_clear(struct treeset *_set_);
void ts_free(struct treeset *_set_);
void ts_customize(struct treeset *_set_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool ts_insert(struct treeset *_set_, size_t value);
_Bool ts_remove(struct treeset *_set_, size_t value);
_Bool ts_max(struct treeset *_set_, size_t *value);
_Bool ts_min(struct treeset *_set_, size_t *value);
_Bool ts_contains(struct treeset *_set_, size_t value);
_Bool ts_empty(struct treeset *_set_);
size_t ts_count(struct treeset *_set_);
int ts_flag(struct treeset *_set_);
struct treeset *ts_copy_of(struct treeset *_set_);
_Bool ts_equals(struct treeset *_set1_, struct treeset *_set2_);
struct treeset *ts_union(struct treeset *_set1_, struct treeset *_set2_);
struct treeset *ts_intersection(struct treeset *_set1_, struct treeset *_set2_);
struct treeset *ts_difference(struct treeset *_set1_, struct treeset *_set2_);
struct treeset *ts_symmetric_difference(struct treeset *_set1_, struct treeset *_set2_);
_Bool ts_is_subset(struct treeset *_set1_, struct treeset *_set2_);
_Bool ts_is_superset(struct treeset *_set1_, struct treeset *_set2_);
_Bool ts_is_proper_subset(struct treeset *_set1_, struct treeset *_set2_);
_Bool ts_is_proper_superset(struct treeset *_set1_, struct treeset *_set2_);
_Bool ts_is_disjointset(struct treeset *_set1_, struct treeset *_set2_);
struct treeset_iter ts_iter_start(struct treeset *target);
struct treeset_iter ts_iter_end(struct treeset *target);
_Bool ts_iter_at_start(struct treeset_iter *iter);
_Bool ts_iter_at_end(struct treeset_iter *iter);
_Bool ts_iter_to_start(struct treeset_iter *iter);
_Bool ts_iter_to_end(struct treeset_iter *iter);
_Bool ts_iter_next(struct treeset_iter *iter);
_Bool ts_iter_prev(struct treeset_iter *iter);
_Bool ts_iter_advance(struct treeset_iter *iter, size_t steps);
_Bool ts_iter_rewind(struct treeset_iter *iter, size_t steps);
_Bool ts_iter_go_to(struct treeset_iter *iter, size_t index);
size_t ts_iter_value(struct treeset_iter *iter);
size_t ts_iter_index(struct treeset_iter *iter);
_Bool ts_to_string(struct treeset *_set_, FILE *fptr);
_Bool ts_print(struct treeset *_set_, FILE *fptr, const char *start, const char *separator, const char *end);
static struct treeset_node *ts_impl_new_node(struct treeset *_set_, size_t value);
static struct treeset_node *ts_impl_get_node(struct treeset *_set_, size_t value);
static unsigned char ts_impl_h(struct treeset_node *node);
@@ -917,5 +839,3 @@ _Bool ts_print(struct treeset *_set_, FILE *fptr, const char *start, const char
fprintf(fptr, "%s", end);
return 1;
}
#endif /* CMC_TEST_SRC_TREESET */
@@ -1,13 +1,14 @@
#include "utl.c"
#include "utl/assert.h"
#include "utl/test.h"
#ifndef CMC_TESTS_UNT_CMC_ITSET_H
#define CMC_TESTS_UNT_CMC_ITSET_H
#include "../src/bitset.c"
#include "../utl.h"
#include "cmc/bitset.h"
struct cmc_alloc_node *bs_alloc_node =
&(struct cmc_alloc_node){ .malloc = malloc, .calloc = calloc, .realloc = realloc, .free = free };
CMC_CREATE_UNIT(BitSet, true, {
CMC_CREATE_UNIT(CMCBitSet, true, {
const size_t word_bits = sizeof(cmc_bitset_word) * CHAR_BIT;
printf("%s", cmc_test_color(5));
@@ -20,7 +21,10 @@ CMC_CREATE_UNIT(BitSet, true, {
cmc_assert_not_equals(ptr, NULL, bs);
cmc_assert_not_equals(ptr, NULL, bs->buffer);
cmc_assert_equals(size_t, bs_bit_to_index(63) + 1, bs->capacity);
cmc_assert_equals(ptr, &cmc_alloc_node_default, bs->alloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.malloc, bs->alloc->malloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.calloc, bs->alloc->calloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.realloc, bs->alloc->realloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.free, bs->alloc->free);
cmc_assert_equals(ptr, NULL, bs->callbacks);
bs_free(bs);
@@ -62,7 +66,10 @@ CMC_CREATE_UNIT(BitSet, true, {
cmc_assert_not_equals(ptr, NULL, bs.buffer);
cmc_assert_equals(size_t, bs_bit_to_index(63) + 1, bs.capacity);
cmc_assert_equals(ptr, &cmc_alloc_node_default, bs.alloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.malloc, bs.alloc->malloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.calloc, bs.alloc->calloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.realloc, bs.alloc->realloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.free, bs.alloc->free);
cmc_assert_equals(ptr, NULL, bs.callbacks);
bs_release(bs);
@@ -114,7 +121,10 @@ CMC_CREATE_UNIT(BitSet, true, {
bs->flag = CMC_FLAG_ERROR;
bs_customize(bs, NULL, NULL);
cmc_assert_equals(ptr, &cmc_alloc_node_default, bs->alloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.malloc, bs->alloc->malloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.calloc, bs->alloc->calloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.realloc, bs->alloc->realloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.free, bs->alloc->free);
cmc_assert_equals(ptr, NULL, bs->callbacks);
cmc_assert_equals(int32_t, CMC_FLAG_OK, bs->flag);
@@ -419,7 +429,7 @@ CMC_CREATE_UNIT(BitSet, true, {
});
});
CMC_CREATE_UNIT(BitSetIter, true, {
CMC_CREATE_UNIT(CMCBitSetIter, true, {
// const size_t word_bytes = sizeof(cmc_bitset_word);
// const size_t word_bits = sizeof(cmc_bitset_word) * CHAR_BIT;
@@ -439,14 +449,16 @@ CMC_CREATE_UNIT(BitSetIter, true, {
#ifdef CMC_TEST_MAIN
int main(void)
{
int result = BitSet() + BitSetIter();
int result = CMCBitSet() + CMCBitSetIter();
printf(" +---------------------------------------------------------------+");
printf("\n");
printf(" | BitSet Suit : %-47s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" | CMCBitSet Suit : %-47s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" +---------------------------------------------------------------+");
printf("\n\n\n");
return result;
}
#endif
#endif /* CMC_TESTS_UNT_CMC_ITSET_H */
@@ -1,8 +1,9 @@
#include "utl.c"
#include "utl/assert.h"
#include "utl/test.h"
#ifndef CMC_TESTS_UNT_CMC_EQUE_H
#define CMC_TESTS_UNT_CMC_EQUE_H
#include "../src/deque.c"
#include "../utl.h"
#include "cmc/deque.h"
struct deque_fval *d_fval = &(struct deque_fval){
.cmp = cmc_size_cmp, .cpy = NULL, .str = cmc_size_str, .free = NULL, .hash = cmc_size_hash, .pri = cmc_size_cmp
@@ -15,7 +16,7 @@ struct deque_fval *d_fval_counter = &(struct deque_fval){
struct cmc_alloc_node *d_alloc_node =
&(struct cmc_alloc_node){ .malloc = malloc, .calloc = calloc, .realloc = realloc, .free = free };
CMC_CREATE_UNIT(Deque, true, {
CMC_CREATE_UNIT(CMCDeque, true, {
CMC_CREATE_TEST(PFX##_new(), {
struct deque *d = d_new(1000000, d_fval);
@@ -27,7 +28,10 @@ CMC_CREATE_UNIT(Deque, true, {
cmc_assert_equals(size_t, 0, d->back);
cmc_assert_equals(int32_t, CMC_FLAG_OK, d->flag);
cmc_assert_equals(ptr, d_fval, d->f_val);
cmc_assert_equals(ptr, &cmc_alloc_node_default, d->alloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.malloc, d->alloc->malloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.calloc, d->alloc->calloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.realloc, d->alloc->realloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.free, d->alloc->free);
cmc_assert_equals(ptr, NULL, d->callbacks);
d_free(d);
@@ -68,74 +72,77 @@ CMC_CREATE_UNIT(Deque, true, {
cmc_assert_equals(ptr, NULL, d);
});
// CMC_CREATE_TEST(PFX##_init(), {
// struct deque d = d_init(1000000, d_fval);
CMC_CREATE_TEST(PFX##_init(), {
struct deque d = d_init(1000000, d_fval);
// cmc_assert_not_equals(ptr, NULL, d.buffer);
// cmc_assert_equals(size_t, 1000000, d.capacity);
// cmc_assert_equals(size_t, 0, d.count);
// cmc_assert_equals(size_t, 0, d.front);
// cmc_assert_equals(size_t, 0, d.back);
// cmc_assert_equals(int32_t, CMC_FLAG_OK, d.flag);
// cmc_assert_equals(ptr, d_fval, d.f_val);
// cmc_assert_equals(ptr, &cmc_alloc_node_default, d.alloc);
// cmc_assert_equals(ptr, NULL, d.callbacks);
cmc_assert_not_equals(ptr, NULL, d.buffer);
cmc_assert_equals(size_t, 1000000, d.capacity);
cmc_assert_equals(size_t, 0, d.count);
cmc_assert_equals(size_t, 0, d.front);
cmc_assert_equals(size_t, 0, d.back);
cmc_assert_equals(int32_t, CMC_FLAG_OK, d.flag);
cmc_assert_equals(ptr, d_fval, d.f_val);
cmc_assert_equals(ptr, cmc_alloc_node_default.malloc, d.alloc->malloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.calloc, d.alloc->calloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.realloc, d.alloc->realloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.free, d.alloc->free);
cmc_assert_equals(ptr, NULL, d.callbacks);
// d_release(d);
d_release(d);
// d = d_init(0, d_fval);
d = d_init(0, d_fval);
// cmc_assert_equals(size_t, 0, d.capacity);
// cmc_assert_equals(ptr, NULL, d.buffer);
cmc_assert_equals(size_t, 0, d.capacity);
cmc_assert_equals(ptr, NULL, d.buffer);
// d = d_init(1000, NULL);
d = d_init(1000, NULL);
// cmc_assert_equals(size_t, 0, d.capacity);
// cmc_assert_equals(ptr, NULL, d.buffer);
cmc_assert_equals(size_t, 0, d.capacity);
cmc_assert_equals(ptr, NULL, d.buffer);
// d = d_init(UINT64_MAX, d_fval);
d = d_init(UINT64_MAX, d_fval);
// cmc_assert_equals(size_t, 0, d.capacity);
// cmc_assert_equals(ptr, NULL, d.buffer);
cmc_assert_equals(size_t, 0, d.capacity);
cmc_assert_equals(ptr, NULL, d.buffer);
// if (d.buffer)
// d_release(d);
// });
if (d.buffer)
d_release(d);
});
// CMC_CREATE_TEST(PFX##_init_custom(), {
// struct deque d =
// d_init_custom(1000000, d_fval, d_alloc_node, callbacks);
CMC_CREATE_TEST(PFX##_init_custom(), {
struct deque d =
d_init_custom(1000000, d_fval, d_alloc_node, callbacks);
// cmc_assert_not_equals(ptr, NULL, d.buffer);
// cmc_assert_equals(size_t, 1000000, d.capacity);
// cmc_assert_equals(size_t, 0, d.count);
// cmc_assert_equals(size_t, 0, d.front);
// cmc_assert_equals(size_t, 0, d.back);
// cmc_assert_equals(int32_t, CMC_FLAG_OK, d.flag);
// cmc_assert_equals(ptr, d_fval, d.f_val);
// cmc_assert_equals(ptr, d_alloc_node, d.alloc);
// cmc_assert_equals(ptr, callbacks, d.callbacks);
cmc_assert_not_equals(ptr, NULL, d.buffer);
cmc_assert_equals(size_t, 1000000, d.capacity);
cmc_assert_equals(size_t, 0, d.count);
cmc_assert_equals(size_t, 0, d.front);
cmc_assert_equals(size_t, 0, d.back);
cmc_assert_equals(int32_t, CMC_FLAG_OK, d.flag);
cmc_assert_equals(ptr, d_fval, d.f_val);
cmc_assert_equals(ptr, d_alloc_node, d.alloc);
cmc_assert_equals(ptr, callbacks, d.callbacks);
// d_release(d);
d_release(d);
// d = d_init_custom(0, d_fval, d_alloc_node, callbacks);
d = d_init_custom(0, d_fval, d_alloc_node, callbacks);
// cmc_assert_equals(size_t, 0, d.capacity);
// cmc_assert_equals(ptr, NULL, d.buffer);
cmc_assert_equals(size_t, 0, d.capacity);
cmc_assert_equals(ptr, NULL, d.buffer);
// d = d_init_custom(1000, NULL, d_alloc_node, callbacks);
d = d_init_custom(1000, NULL, d_alloc_node, callbacks);
// cmc_assert_equals(size_t, 0, d.capacity);
// cmc_assert_equals(ptr, NULL, d.buffer);
cmc_assert_equals(size_t, 0, d.capacity);
cmc_assert_equals(ptr, NULL, d.buffer);
// d = d_init_custom(UINT64_MAX, d_fval, d_alloc_node, callbacks);
d = d_init_custom(UINT64_MAX, d_fval, d_alloc_node, callbacks);
// cmc_assert_equals(size_t, 0, d.capacity);
// cmc_assert_equals(ptr, NULL, d.buffer);
cmc_assert_equals(size_t, 0, d.capacity);
cmc_assert_equals(ptr, NULL, d.buffer);
// if (d.buffer)
// d_release(d);
// });
if (d.buffer)
d_release(d);
});
CMC_CREATE_TEST(PFX##_clear(), {
v_total_free = 0;
@@ -222,36 +229,36 @@ CMC_CREATE_UNIT(Deque, true, {
v_total_free = 0;
});
// CMC_CREATE_TEST(PFX##_release(), {
// v_total_free = 0;
CMC_CREATE_TEST(PFX##_release(), {
v_total_free = 0;
// struct deque d = d_init(100, d_fval_counter);
struct deque d = d_init(100, d_fval_counter);
// cmc_assert_not_equals(ptr, NULL, d.buffer);
cmc_assert_not_equals(ptr, NULL, d.buffer);
// for (size_t i = 1; i <= 1000; i++)
// {
// if (i % 2 == 0)
// d_push_front(&d, i);
// else
// d_push_back(&d, i);
// }
for (size_t i = 1; i <= 1000; i++)
{
if (i % 2 == 0)
d_push_front(&d, i);
else
d_push_back(&d, i);
}
// cmc_assert_equals(size_t, 1000, d_count(&d));
cmc_assert_equals(size_t, 1000, d_count(&d));
// size_t sum = 0;
// for (size_t i = d.front, j = 0; j < d.count;
// i = (i + 1) % d.capacity, j++)
// sum += d.buffer[i];
size_t sum = 0;
for (size_t i = d.front, j = 0; j < d.count;
i = (i + 1) % d.capacity, j++)
sum += d.buffer[i];
// cmc_assert_equals(size_t, 500500, sum);
cmc_assert_equals(size_t, 500500, sum);
// d_release(d);
d_release(d);
// cmc_assert_equals(size_t, 1000, v_total_free);
cmc_assert_equals(size_t, 1000, v_total_free);
// v_total_free = 0;
// });
v_total_free = 0;
});
CMC_CREATE_TEST(PFX##_customize(), {
struct deque *d = d_new(100, d_fval);
@@ -268,7 +275,10 @@ CMC_CREATE_UNIT(Deque, true, {
d->flag = CMC_FLAG_ERROR;
d_customize(d, NULL, NULL);
cmc_assert_equals(ptr, &cmc_alloc_node_default, d->alloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.malloc, d->alloc->malloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.calloc, d->alloc->calloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.realloc, d->alloc->realloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.free, d->alloc->free);
cmc_assert_equals(ptr, NULL, d->callbacks);
cmc_assert_equals(int32_t, CMC_FLAG_OK, d_flag(d));
@@ -1253,7 +1263,7 @@ CMC_CREATE_UNIT(Deque, true, {
});
});
CMC_CREATE_UNIT(DequeIter, true, {
CMC_CREATE_UNIT(CMCDequeIter, true, {
CMC_CREATE_TEST(PFX##_iter_start(), {
struct deque *d = d_new(100, d_fval);
@@ -1712,14 +1722,16 @@ CMC_CREATE_UNIT(DequeIter, true, {
#ifdef CMC_TEST_MAIN
int main(void)
{
int result = Deque() + DequeIter();
int result = CMCDeque() + CMCDequeIter();
printf(" +---------------------------------------------------------------+");
printf("\n");
printf(" | Deque Suit : %-48s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" | CMCDeque Suit : %-48s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" +---------------------------------------------------------------+");
printf("\n\n\n");
return result;
}
#endif
#endif /* CMC_TESTS_UNT_CMC_EQUE_H */
@@ -1,8 +1,9 @@
#include "utl.c"
#include "utl/assert.h"
#include "utl/test.h"
#ifndef CMC_TESTS_UNT_CMC_ASHBIDIMAP_H
#define CMC_TESTS_UNT_CMC_ASHBIDIMAP_H
#include "../src/hashbidimap.c"
#include "../utl.h"
#include "cmc/hashbidimap.h"
struct hashbidimap_fkey *hbm_fkey = &(struct hashbidimap_fkey){
.cmp = cmc_size_cmp, .cpy = NULL, .str = cmc_size_str, .free = NULL, .hash = cmc_size_hash, .pri = cmc_size_cmp
@@ -23,7 +24,7 @@ struct hashbidimap_fval *hbm_fval_counter = &(struct hashbidimap_fval){
struct cmc_alloc_node *hbm_alloc_node =
&(struct cmc_alloc_node){ .malloc = malloc, .calloc = calloc, .realloc = realloc, .free = free };
CMC_CREATE_UNIT(HashBidiMap, true, {
CMC_CREATE_UNIT(CMCHashBidiMap, true, {
CMC_CREATE_TEST(PFX##_new(), {
struct hashbidimap *map = hbm_new(943722, 0.6, hbm_fkey, hbm_fval);
@@ -34,7 +35,10 @@ CMC_CREATE_UNIT(HashBidiMap, true, {
cmc_assert_equals(int32_t, CMC_FLAG_OK, map->flag);
cmc_assert_equals(ptr, hbm_fkey, map->f_key);
cmc_assert_equals(ptr, hbm_fval, map->f_val);
cmc_assert_equals(ptr, &cmc_alloc_node_default, map->alloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.malloc, map->alloc->malloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.calloc, map->alloc->calloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.realloc, map->alloc->realloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.free, map->alloc->free);
cmc_assert_equals(ptr, NULL, map->callbacks);
cmc_assert_greater_equals(size_t, (943722 / 0.6), hbm_capacity(map));
@@ -162,7 +166,10 @@ CMC_CREATE_UNIT(HashBidiMap, true, {
cmc_assert_not_equals(ptr, NULL, map);
cmc_assert_equals(ptr, &cmc_alloc_node_default, map->alloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.malloc, map->alloc->malloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.calloc, map->alloc->calloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.realloc, map->alloc->realloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.free, map->alloc->free);
cmc_assert_equals(ptr, NULL, map->callbacks);
hbm_free(map);
@@ -793,7 +800,7 @@ CMC_CREATE_UNIT(HashBidiMap, true, {
});
});
CMC_CREATE_UNIT(HashBidiMapIter, true, {
CMC_CREATE_UNIT(CMCHashBidiMapIter, true, {
CMC_CREATE_TEST(PFX##_iter_start, {
// WIP
cmc_assert(true);
@@ -804,14 +811,16 @@ CMC_CREATE_UNIT(HashBidiMapIter, true, {
#ifdef CMC_TEST_MAIN
int main(void)
{
int result = HashBidiMap() + HashBidiMapIter();
int result = CMCHashBidiMap() + CMCHashBidiMapIter();
printf(" +---------------------------------------------------------------+");
printf("\n");
printf(" | HashBidiMap Suit : %-42s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" | CMCHashBidiMap Suit : %-42s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" +---------------------------------------------------------------+");
printf("\n\n\n");
return result;
}
#endif
#endif /* CMC_TESTS_UNT_CMC_ASHBIDIMAP_H */
@@ -1,8 +1,9 @@
#include "utl.c"
#include "utl/assert.h"
#include "utl/test.h"
#ifndef CMC_TESTS_UNT_CMC_ASHMAP_H
#define CMC_TESTS_UNT_CMC_ASHMAP_H
#include "../src/hashmap.c"
#include "../utl.h"
#include "cmc/hashmap.h"
struct hashmap_fkey *hm_fkey = &(struct hashmap_fkey){
.cmp = cmc_size_cmp, .cpy = NULL, .str = cmc_size_str, .free = NULL, .hash = cmc_size_hash, .pri = cmc_size_cmp
@@ -23,7 +24,7 @@ struct hashmap_fval *hm_fval_counter = &(struct hashmap_fval){
struct cmc_alloc_node *hm_alloc_node =
&(struct cmc_alloc_node){ .malloc = malloc, .calloc = calloc, .realloc = realloc, .free = free };
CMC_CREATE_UNIT(HashMap, true, {
CMC_CREATE_UNIT(CMCHashMap, true, {
CMC_CREATE_TEST(PFX##_new(), {
struct hashmap *map = hm_new(943722, 0.6, hm_fkey, hm_fval);
@@ -34,7 +35,10 @@ CMC_CREATE_UNIT(HashMap, true, {
cmc_assert_equals(int32_t, CMC_FLAG_OK, map->flag);
cmc_assert_equals(ptr, hm_fkey, map->f_key);
cmc_assert_equals(ptr, hm_fval, map->f_val);
cmc_assert_equals(ptr, &cmc_alloc_node_default, map->alloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.malloc, map->alloc->malloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.calloc, map->alloc->calloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.realloc, map->alloc->realloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.free, map->alloc->free);
cmc_assert_equals(ptr, NULL, map->callbacks);
cmc_assert_greater_equals(size_t, (943722 / 0.6), hm_capacity(map));
@@ -90,70 +94,73 @@ CMC_CREATE_UNIT(HashMap, true, {
cmc_assert_equals(ptr, NULL, map);
});
// CMC_CREATE_TEST(PFX##_init(), {
// struct hashmap map = hm_init(943722, 0.6, hm_fkey, hm_fval);
CMC_CREATE_TEST(PFX##_init(), {
struct hashmap map = hm_init(943722, 0.6, hm_fkey, hm_fval);
// cmc_assert_not_equals(ptr, NULL, map.buffer);
// cmc_assert_equals(size_t, 0, map.count);
// cmc_assert_equals(double, 0.6, map.load);
// cmc_assert_equals(int32_t, CMC_FLAG_OK, map.flag);
// cmc_assert_equals(ptr, hm_fkey, map.f_key);
// cmc_assert_equals(ptr, hm_fval, map.f_val);
// cmc_assert_equals(ptr, &cmc_alloc_node_default, map.alloc);
// cmc_assert_equals(ptr, NULL, map.callbacks);
cmc_assert_not_equals(ptr, NULL, map.buffer);
cmc_assert_equals(size_t, 0, map.count);
cmc_assert_equals(double, 0.6, map.load);
cmc_assert_equals(int32_t, CMC_FLAG_OK, map.flag);
cmc_assert_equals(ptr, hm_fkey, map.f_key);
cmc_assert_equals(ptr, hm_fval, map.f_val);
cmc_assert_equals(ptr, cmc_alloc_node_default.malloc, map.alloc->malloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.calloc, map.alloc->calloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.realloc, map.alloc->realloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.free, map.alloc->free);
cmc_assert_equals(ptr, NULL, map.callbacks);
// cmc_assert_greater_equals(size_t, (943722 / 0.6), hm_capacity(&map));
cmc_assert_greater_equals(size_t, (943722 / 0.6), hm_capacity(&map));
// hm_release(map);
hm_release(map);
// map = hm_init(0, 0.6, hm_fkey, hm_fval);
// cmc_assert_equals(ptr, NULL, map.buffer);
map = hm_init(0, 0.6, hm_fkey, hm_fval);
cmc_assert_equals(ptr, NULL, map.buffer);
// map = hm_init(UINT64_MAX, 0.99, hm_fkey, hm_fval);
// cmc_assert_equals(ptr, NULL, map.buffer);
map = hm_init(UINT64_MAX, 0.99, hm_fkey, hm_fval);
cmc_assert_equals(ptr, NULL, map.buffer);
// map = hm_init(1000, 0.6, hm_fkey, NULL);
// cmc_assert_equals(ptr, NULL, map.buffer);
map = hm_init(1000, 0.6, hm_fkey, NULL);
cmc_assert_equals(ptr, NULL, map.buffer);
// map = hm_init(1000, 0.6, NULL, hm_fval);
// cmc_assert_equals(ptr, NULL, map.buffer);
map = hm_init(1000, 0.6, NULL, hm_fval);
cmc_assert_equals(ptr, NULL, map.buffer);
// map = hm_init(1000, 0.6, NULL, NULL);
// cmc_assert_equals(ptr, NULL, map.buffer);
// });
map = hm_init(1000, 0.6, NULL, NULL);
cmc_assert_equals(ptr, NULL, map.buffer);
});
// CMC_CREATE_TEST(PFX##_init_custom(), {
// struct hashmap map = hm_init_custom(943722, 0.6, hm_fkey, hm_fval,
// hm_alloc_node, callbacks);
CMC_CREATE_TEST(PFX##_init_custom(), {
struct hashmap map = hm_init_custom(943722, 0.6, hm_fkey, hm_fval,
hm_alloc_node, callbacks);
// cmc_assert_not_equals(ptr, NULL, map.buffer);
// cmc_assert_equals(size_t, 0, map.count);
// cmc_assert_equals(double, 0.6, map.load);
// cmc_assert_equals(int32_t, CMC_FLAG_OK, map.flag);
// cmc_assert_equals(ptr, hm_fkey, map.f_key);
// cmc_assert_equals(ptr, hm_fval, map.f_val);
// cmc_assert_equals(ptr, hm_alloc_node, map.alloc);
// cmc_assert_equals(ptr, callbacks, map.callbacks);
cmc_assert_not_equals(ptr, NULL, map.buffer);
cmc_assert_equals(size_t, 0, map.count);
cmc_assert_equals(double, 0.6, map.load);
cmc_assert_equals(int32_t, CMC_FLAG_OK, map.flag);
cmc_assert_equals(ptr, hm_fkey, map.f_key);
cmc_assert_equals(ptr, hm_fval, map.f_val);
cmc_assert_equals(ptr, hm_alloc_node, map.alloc);
cmc_assert_equals(ptr, callbacks, map.callbacks);
// cmc_assert_greater_equals(size_t, (943722 / 0.6), hm_capacity(&map));
cmc_assert_greater_equals(size_t, (943722 / 0.6), hm_capacity(&map));
// hm_release(map);
hm_release(map);
// map = hm_init_custom(0, 0.6, hm_fkey, hm_fval, NULL, NULL);
// cmc_assert_equals(ptr, NULL, map.buffer);
map = hm_init_custom(0, 0.6, hm_fkey, hm_fval, NULL, NULL);
cmc_assert_equals(ptr, NULL, map.buffer);
// map = hm_init_custom(UINT64_MAX, 0.99, hm_fkey, hm_fval, NULL, NULL);
// cmc_assert_equals(ptr, NULL, map.buffer);
map = hm_init_custom(UINT64_MAX, 0.99, hm_fkey, hm_fval, NULL, NULL);
cmc_assert_equals(ptr, NULL, map.buffer);
// map = hm_init_custom(1000, 0.6, hm_fkey, NULL, NULL, NULL);
// cmc_assert_equals(ptr, NULL, map.buffer);
map = hm_init_custom(1000, 0.6, hm_fkey, NULL, NULL, NULL);
cmc_assert_equals(ptr, NULL, map.buffer);
// map = hm_init_custom(1000, 0.6, NULL, hm_fval, NULL, NULL);
// cmc_assert_equals(ptr, NULL, map.buffer);
map = hm_init_custom(1000, 0.6, NULL, hm_fval, NULL, NULL);
cmc_assert_equals(ptr, NULL, map.buffer);
// map = hm_init_custom(1000, 0.6, NULL, NULL, NULL, NULL);
// cmc_assert_equals(ptr, NULL, map.buffer);
// });
map = hm_init_custom(1000, 0.6, NULL, NULL, NULL, NULL);
cmc_assert_equals(ptr, NULL, map.buffer);
});
CMC_CREATE_TEST(PFX##_clear(), {
k_total_free = 0;
@@ -217,35 +224,35 @@ CMC_CREATE_UNIT(HashMap, true, {
v_total_free = 0;
});
// CMC_CREATE_TEST(PFX##_release(), {
// k_total_free = 0;
// v_total_free = 0;
// struct hashmap map =
// hm_init(100, 0.6, hm_fkey_counter, hm_fval_counter);
CMC_CREATE_TEST(PFX##_release(), {
k_total_free = 0;
v_total_free = 0;
struct hashmap map =
hm_init(100, 0.6, hm_fkey_counter, hm_fval_counter);
// cmc_assert_not_equals(ptr, NULL, map.buffer);
cmc_assert_not_equals(ptr, NULL, map.buffer);
// for (size_t i = 1; i <= 1000; i++)
// hm_insert(&map, i, i);
for (size_t i = 1; i <= 1000; i++)
hm_insert(&map, i, i);
// cmc_assert_equals(size_t, 1000, map.count);
cmc_assert_equals(size_t, 1000, map.count);
// hm_release(map);
hm_release(map);
// cmc_assert_equals(int32_t, 1000, k_total_free);
// cmc_assert_equals(int32_t, 1000, v_total_free);
cmc_assert_equals(int32_t, 1000, k_total_free);
cmc_assert_equals(int32_t, 1000, v_total_free);
// map = hm_init(1000, 0.6, hm_fkey_counter, hm_fval_counter);
map = hm_init(1000, 0.6, hm_fkey_counter, hm_fval_counter);
// cmc_assert_not_equals(ptr, NULL, map.buffer);
cmc_assert_not_equals(ptr, NULL, map.buffer);
// hm_release(map);
hm_release(map);
// cmc_assert_equals(int32_t, 1000, k_total_free);
// cmc_assert_equals(int32_t, 1000, v_total_free);
// k_total_free = 0;
// v_total_free = 0;
// });
cmc_assert_equals(int32_t, 1000, k_total_free);
cmc_assert_equals(int32_t, 1000, v_total_free);
k_total_free = 0;
v_total_free = 0;
});
CMC_CREATE_TEST(PFX##_customize(), {
struct hashmap *map = hm_new(100, 0.6, hm_fkey, hm_fval);
@@ -262,7 +269,10 @@ CMC_CREATE_UNIT(HashMap, true, {
map->flag = CMC_FLAG_ERROR;
hm_customize(map, NULL, NULL);
cmc_assert_equals(ptr, &cmc_alloc_node_default, map->alloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.malloc, map->alloc->malloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.calloc, map->alloc->calloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.realloc, map->alloc->realloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.free, map->alloc->free);
cmc_assert_equals(ptr, NULL, map->callbacks);
cmc_assert_equals(int32_t, CMC_FLAG_OK, map->flag);
@@ -370,8 +380,8 @@ CMC_CREATE_UNIT(HashMap, true, {
for (size_t i = 0; i < 6; i++)
cmc_assert(hm_insert(map, i, i));
for (size_t i = 0; i < 6; i++)
cmc_assert_equals(size_t, i, hm_impl_get_entry(map, i)->dist);
// for (size_t i = 0; i < 6; i++)
// cmc_assert_equals(size_t, i, hm_impl_get_entry(map, i)->dist);
hm_fkey->hash = cmc_size_hash;
@@ -874,7 +884,7 @@ struct hashmap_fkey *hm_fkey_numhash = &(struct hashmap_fkey){
.cmp = cmc_size_cmp, .cpy = NULL, .str = cmc_size_str, .free = NULL, .hash = numhash, .pri = cmc_size_cmp
};
CMC_CREATE_UNIT(HashMapIter, true, {
CMC_CREATE_UNIT(CMCHashMapIter, true, {
CMC_CREATE_TEST(PFX##_iter_start(), {
struct hashmap *map = hm_new(100, 0.6, hm_fkey_numhash, hm_fval);
@@ -1318,14 +1328,16 @@ CMC_CREATE_UNIT(HashMapIter, true, {
#ifdef CMC_TEST_MAIN
int main(void)
{
int result = HashMap() + HashMapIter();
int result = CMCHashMap() + CMCHashMapIter();
printf(" +---------------------------------------------------------------+");
printf("\n");
printf(" | HashMap Suit : %-46s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" | CMCHashMap Suit : %-46s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" +---------------------------------------------------------------+");
printf("\n\n\n");
return result;
}
#endif
#endif /* CMC_TESTS_UNT_CMC_ASHMAP_H */
@@ -1,8 +1,9 @@
#include "utl.c"
#include "utl/assert.h"
#include "utl/test.h"
#ifndef CMC_TESTS_UNT_CMC_ASHMULTIMAP_H
#define CMC_TESTS_UNT_CMC_ASHMULTIMAP_H
#include "../src/hashmultimap.c"
#include "../utl.h"
#include "cmc/hashmultimap.h"
struct hashmultimap_fkey *hmm_fkey = &(struct hashmultimap_fkey){
.cmp = cmc_size_cmp, .cpy = NULL, .str = cmc_size_str, .free = NULL, .hash = cmc_size_hash, .pri = cmc_size_cmp
@@ -23,7 +24,7 @@ struct hashmultimap_fval *hmm_fval_counter = &(struct hashmultimap_fval){
struct cmc_alloc_node *hmm_alloc_node =
&(struct cmc_alloc_node){ .malloc = malloc, .calloc = calloc, .realloc = realloc, .free = free };
CMC_CREATE_UNIT(HashMultiMap, true, {
CMC_CREATE_UNIT(CMCHashMultiMap, true, {
CMC_CREATE_TEST(PFX##_new(), {
struct hashmultimap *map = hmm_new(943722, 0.6, hmm_fkey, hmm_fval);
@@ -34,7 +35,10 @@ CMC_CREATE_UNIT(HashMultiMap, true, {
cmc_assert_equals(int32_t, CMC_FLAG_OK, map->flag);
cmc_assert_equals(ptr, hmm_fkey, map->f_key);
cmc_assert_equals(ptr, hmm_fval, map->f_val);
cmc_assert_equals(ptr, &cmc_alloc_node_default, map->alloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.malloc, map->alloc->malloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.calloc, map->alloc->calloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.realloc, map->alloc->realloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.free, map->alloc->free);
cmc_assert_equals(ptr, NULL, map->callbacks);
cmc_assert_greater_equals(size_t, (943722 / 0.6), hmm_capacity(map));
@@ -464,7 +468,7 @@ struct hashmultimap_fkey *hmm_fkey_numhash = &(struct hashmultimap_fkey){
.cmp = cmc_size_cmp, .cpy = NULL, .str = cmc_size_str, .free = NULL, .hash = numhash, .pri = cmc_size_cmp
};
CMC_CREATE_UNIT(HashMultiMapIter, true, {
CMC_CREATE_UNIT(CMCHashMultiMapIter, true, {
CMC_CREATE_TEST(PFX##_iter_start(), {
struct hashmultimap *map = hmm_new(100, 0.6, hmm_fkey_numhash, hmm_fval);
@@ -908,14 +912,16 @@ CMC_CREATE_UNIT(HashMultiMapIter, true, {
#ifdef CMC_TEST_MAIN
int main(void)
{
int result = HashMultiMap() + HashMultiMapIter();
int result = CMCHashMultiMap() + CMCHashMultiMapIter();
printf(" +---------------------------------------------------------------+");
printf("\n");
printf(" | HashMultiMap Suit : %-41s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" | CMCHashMultiMap Suit : %-41s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" +---------------------------------------------------------------+");
printf("\n\n\n");
return result;
}
#endif
#endif /* CMC_TESTS_UNT_CMC_ASHMULTIMAP_H */
@@ -1,8 +1,9 @@
#include "utl.c"
#include "utl/assert.h"
#include "utl/test.h"
#ifndef CMC_TESTS_UNT_CMC_ASHMULTISET_H
#define CMC_TESTS_UNT_CMC_ASHMULTISET_H
#include "../src/hashmultiset.c"
#include "../utl.h"
#include "cmc/hashmultiset.h"
struct hashmultiset_fval *hms_fval = &(struct hashmultiset_fval){
.cmp = cmc_size_cmp, .cpy = NULL, .str = cmc_size_str, .free = NULL, .hash = cmc_size_hash, .pri = cmc_size_cmp
@@ -15,7 +16,7 @@ struct hashmultiset_fval *hms_fval_counter = &(struct hashmultiset_fval){
struct cmc_alloc_node *hms_alloc_node =
&(struct cmc_alloc_node){ .malloc = malloc, .calloc = calloc, .realloc = realloc, .free = free };
CMC_CREATE_UNIT(HashMultiSet, true, {
CMC_CREATE_UNIT(CMCHashMultiSet, true, {
CMC_CREATE_TEST(PFX##_new(), {
struct hashmultiset *set = hms_new(943722, 0.6, hms_fval);
@@ -25,7 +26,10 @@ CMC_CREATE_UNIT(HashMultiSet, true, {
cmc_assert_equals(double, 0.6, set->load);
cmc_assert_equals(int32_t, CMC_FLAG_OK, set->flag);
cmc_assert_equals(ptr, hms_fval, set->f_val);
cmc_assert_equals(ptr, &cmc_alloc_node_default, set->alloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.malloc, set->alloc->malloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.calloc, set->alloc->calloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.realloc, set->alloc->realloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.free, set->alloc->free);
cmc_assert_equals(ptr, NULL, set->callbacks);
cmc_assert_greater_equals(size_t, (943722 / 0.6), hms_capacity(set));
@@ -418,7 +422,7 @@ struct hashmultiset_fval *hms_fval_numhash = &(struct hashmultiset_fval){
.cmp = cmc_size_cmp, .cpy = NULL, .str = cmc_size_str, .free = NULL, .hash = numhash, .pri = cmc_size_cmp
};
CMC_CREATE_UNIT(HashMultiSetIter, true, {
CMC_CREATE_UNIT(CMCHashMultiSetIter, true, {
CMC_CREATE_TEST(PFX##_iter_start(), {
struct hashmultiset *set = hms_new(100, 0.6, hms_fval_numhash);
@@ -845,14 +849,16 @@ CMC_CREATE_UNIT(HashMultiSetIter, true, {
#ifdef CMC_TEST_MAIN
int main(void)
{
int result = HashMultiSet() + HashMultiSetIter();
int result = CMCHashMultiSet() + CMCHashMultiSetIter();
printf(" +---------------------------------------------------------------+");
printf("\n");
printf(" | HashMultiSet Suit : %-41s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" | CMCHashMultiSet Suit : %-41s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" +---------------------------------------------------------------+");
printf("\n\n\n");
return result;
}
#endif
#endif /* CMC_TESTS_UNT_CMC_ASHMULTISET_H */
@@ -1,8 +1,9 @@
#include "utl.c"
#include "utl/assert.h"
#include "utl/test.h"
#ifndef CMC_TESTS_UNT_CMC_ASHSET_H
#define CMC_TESTS_UNT_CMC_ASHSET_H
#include "../src/hashset.c"
#include "../utl.h"
#include "cmc/hashset.h"
struct hashset_fval *hs_fval = &(struct hashset_fval){
.cmp = cmc_size_cmp, .cpy = NULL, .str = cmc_size_str, .free = NULL, .hash = cmc_size_hash, .pri = cmc_size_cmp
@@ -15,7 +16,7 @@ struct hashset_fval *hs_fval_counter = &(struct hashset_fval){
struct cmc_alloc_node *hs_alloc_node =
&(struct cmc_alloc_node){ .malloc = malloc, .calloc = calloc, .realloc = realloc, .free = free };
CMC_CREATE_UNIT(HashSet, true, {
CMC_CREATE_UNIT(CMCHashSet, true, {
CMC_CREATE_TEST(PFX##_new(), {
struct hashset *set = hs_new(943722, 0.6, hs_fval);
@@ -25,7 +26,10 @@ CMC_CREATE_UNIT(HashSet, true, {
cmc_assert_equals(double, 0.6, set->load);
cmc_assert_equals(int32_t, CMC_FLAG_OK, set->flag);
cmc_assert_equals(ptr, hs_fval, set->f_val);
cmc_assert_equals(ptr, &cmc_alloc_node_default, set->alloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.malloc, set->alloc->malloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.calloc, set->alloc->calloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.realloc, set->alloc->realloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.free, set->alloc->free);
cmc_assert_equals(ptr, NULL, set->callbacks);
cmc_assert_greater_equals(size_t, (943722 / 0.6), hs_capacity(set));
@@ -224,8 +228,8 @@ CMC_CREATE_UNIT(HashSet, true, {
for (size_t i = 0; i < 6; i++)
cmc_assert(hs_insert(set, i));
for (size_t i = 0; i < 6; i++)
cmc_assert_equals(size_t, i, hs_impl_get_entry(set, i)->dist);
// for (size_t i = 0; i < 6; i++)
// cmc_assert_equals(size_t, i, hs_impl_get_entry(set, i)->dist);
hs_fval->hash = cmc_size_hash;
@@ -618,7 +622,7 @@ struct hashset_fval *hs_fval_numhash = &(struct hashset_fval){
.cmp = cmc_size_cmp, .cpy = NULL, .str = cmc_size_str, .free = NULL, .hash = numhash, .pri = cmc_size_cmp
};
CMC_CREATE_UNIT(HashSetIter, true, {
CMC_CREATE_UNIT(CMCHashSetIter, true, {
CMC_CREATE_TEST(PFX##_iter_start(), {
struct hashset *set = hs_new(100, 0.6, hs_fval_numhash);
@@ -1025,14 +1029,16 @@ CMC_CREATE_UNIT(HashSetIter, true, {
#ifdef CMC_TEST_MAIN
int main(void)
{
int result = HashSet() + HashSetIter();
int result = CMCHashSet() + CMCHashSetIter();
printf(" +---------------------------------------------------------------+");
printf("\n");
printf(" | HashSet Suit : %-46s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" | CMCHashSet Suit : %-46s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" +---------------------------------------------------------------+");
printf("\n\n\n");
return result;
}
#endif
#endif /* CMC_TESTS_UNT_CMC_ASHSET_H */
+11 -8
View File
@@ -1,14 +1,15 @@
#include "utl.c"
#include "utl/assert.h"
#include "utl/test.h"
#ifndef CMC_TESTS_UNT_CMC_EAP_H
#define CMC_TESTS_UNT_CMC_EAP_H
#include "../src/heap.c"
#include "../utl.h"
#include "cmc/heap.h"
struct heap_fval *h_fval = &(struct heap_fval){
.cmp = cmc_size_cmp, .cpy = NULL, .str = cmc_size_str, .free = NULL, .hash = cmc_size_hash, .pri = cmc_size_cmp
};
CMC_CREATE_UNIT(Heap, true, {
CMC_CREATE_UNIT(CMCHeap, true, {
CMC_CREATE_TEST(new, {
struct heap *h = h_new(1000000, CMC_MAX_HEAP, h_fval);
@@ -286,7 +287,7 @@ CMC_CREATE_UNIT(Heap, true, {
});
});
CMC_CREATE_UNIT(HeapIter, true, {
CMC_CREATE_UNIT(CMCHeapIter, true, {
CMC_CREATE_TEST(PFX##_iter_start(), {
struct heap *h = h_new(100, CMC_MAX_HEAP, h_fval);
@@ -713,14 +714,16 @@ CMC_CREATE_UNIT(HeapIter, true, {
#ifdef CMC_TEST_MAIN
int main(void)
{
int result = Heap() + HeapIter();
int result = CMCHeap() + CMCHeapIter();
printf(" +---------------------------------------------------------------+");
printf("\n");
printf(" | Heap Suit : %-49s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" | CMCHeap Suit : %-49s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" +---------------------------------------------------------------+");
printf("\n\n\n");
return result;
}
#endif
#endif /* CMC_TESTS_UNT_CMC_EAP_H */
@@ -1,8 +1,9 @@
#include "utl.c"
#include "utl/assert.h"
#include "utl/test.h"
#ifndef CMC_TESTS_UNT_CMC_NTERVALHEAP_H
#define CMC_TESTS_UNT_CMC_NTERVALHEAP_H
#include "../src/intervalheap.c"
#include "../utl.h"
#include "cmc/intervalheap.h"
struct intervalheap_fval *ih_fval = &(struct intervalheap_fval){
.cmp = cmc_size_cmp, .cpy = NULL, .str = cmc_size_str, .free = NULL, .hash = cmc_size_hash, .pri = cmc_size_cmp
@@ -15,7 +16,7 @@ struct intervalheap_fval *ih_fval_counter = &(struct intervalheap_fval){
struct cmc_alloc_node *ih_alloc_node =
&(struct cmc_alloc_node){ .malloc = malloc, .calloc = calloc, .realloc = realloc, .free = free };
CMC_CREATE_UNIT(IntervalHeap, true, {
CMC_CREATE_UNIT(CMCIntervalHeap, true, {
CMC_CREATE_TEST(PFX##_new(), {
struct intervalheap *ih = ih_new(1000000, ih_fval);
@@ -86,7 +87,10 @@ CMC_CREATE_UNIT(IntervalHeap, true, {
cmc_assert_not_equals(ptr, NULL, ih);
cmc_assert_equals(size_t, 1, ih_capacity(ih));
cmc_assert_equals(ptr, &cmc_alloc_node_default, ih->alloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.malloc, ih->alloc->malloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.calloc, ih->alloc->calloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.realloc, ih->alloc->realloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.free, ih->alloc->free);
cmc_assert_equals(ptr, NULL, ih->callbacks);
ih_free(ih);
@@ -196,7 +200,10 @@ CMC_CREATE_UNIT(IntervalHeap, true, {
ih->flag = CMC_FLAG_ERROR;
ih_customize(ih, NULL, NULL);
cmc_assert_equals(ptr, &cmc_alloc_node_default, ih->alloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.malloc, ih->alloc->malloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.calloc, ih->alloc->calloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.realloc, ih->alloc->realloc);
cmc_assert_equals(ptr, cmc_alloc_node_default.free, ih->alloc->free);
cmc_assert_equals(ptr, NULL, ih->callbacks);
cmc_assert_equals(int32_t, CMC_FLAG_OK, ih->flag);
@@ -603,7 +610,7 @@ CMC_CREATE_UNIT(IntervalHeap, true, {
});
});
CMC_CREATE_UNIT(IntervalHeapIter, true, {
CMC_CREATE_UNIT(CMCIntervalHeapIter, true, {
CMC_CREATE_TEST(PFX##_iter_start(), {
struct intervalheap *ih = ih_new(100, ih_fval);
@@ -1032,14 +1039,16 @@ CMC_CREATE_UNIT(IntervalHeapIter, true, {
#ifdef CMC_TEST_MAIN
int main(void)
{
int result = IntervalHeap() + IntervalHeapIter();
int result = CMCIntervalHeap() + CMCIntervalHeapIter();
printf(" +---------------------------------------------------------------+");
printf("\n");
printf(" | IntervalHeap Suit : %-41s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" | CMCIntervalHeap Suit : %-41s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" +---------------------------------------------------------------+");
printf("\n\n\n");
return result;
}
#endif
#endif /* CMC_TESTS_UNT_CMC_NTERVALHEAP_H */
@@ -1,14 +1,15 @@
#include "utl.c"
#include "utl/assert.h"
#include "utl/test.h"
#ifndef CMC_TESTS_UNT_CMC_INKEDLIST_H
#define CMC_TESTS_UNT_CMC_INKEDLIST_H
#include "../src/linkedlist.c"
#include "../utl.h"
#include "cmc/linkedlist.h"
struct linkedlist_fval *ll_fval = &(struct linkedlist_fval){
.cmp = cmc_size_cmp, .cpy = NULL, .str = cmc_size_str, .free = NULL, .hash = cmc_size_hash, .pri = cmc_size_cmp
};
CMC_CREATE_UNIT(LinkedList, true, {
CMC_CREATE_UNIT(CMCLinkedList, true, {
CMC_CREATE_TEST(new, {
struct linkedlist *ll = ll_new(ll_fval);
@@ -339,7 +340,7 @@ CMC_CREATE_UNIT(LinkedList, true, {
});
});
CMC_CREATE_UNIT(LinkedListIter, true, {
CMC_CREATE_UNIT(CMCLinkedListIter, true, {
CMC_CREATE_TEST(PFX##_iter_start(), {
struct linkedlist *ll = ll_new(ll_fval);
@@ -798,14 +799,16 @@ CMC_CREATE_UNIT(LinkedListIter, true, {
#ifdef CMC_TEST_MAIN
int main(void)
{
int result = LinkedList() + LinkedListIter();
int result = CMCLinkedList() + CMCLinkedListIter();
printf(" +---------------------------------------------------------------+");
printf("\n");
printf(" | LinkedList Suit : %-43s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" | CMCLinkedList Suit : %-43s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" +---------------------------------------------------------------+");
printf("\n\n\n");
return result;
}
#endif
#endif /* CMC_TESTS_UNT_CMC_INKEDLIST_H */
+11 -8
View File
@@ -1,14 +1,15 @@
#include "utl.c"
#include "utl/assert.h"
#include "utl/test.h"
#ifndef CMC_TESTS_UNT_CMC_LIST_H
#define CMC_TESTS_UNT_CMC_LIST_H
#include "../src/list.c"
#include "../utl.h"
#include "cmc/list.h"
struct list_fval *l_fval = &(struct list_fval){
.cmp = cmc_size_cmp, .cpy = NULL, .str = cmc_size_str, .free = NULL, .hash = cmc_size_hash, .pri = cmc_size_cmp
};
CMC_CREATE_UNIT(List, true, {
CMC_CREATE_UNIT(CMCList, true, {
CMC_CREATE_TEST(new, {
struct list *l = l_new(1000000, l_fval);
@@ -610,7 +611,7 @@ CMC_CREATE_UNIT(List, true, {
});
})
CMC_CREATE_UNIT(ListIter, true, {
CMC_CREATE_UNIT(CMCListIter, true, {
CMC_CREATE_TEST(PFX##_iter_start(), {
struct list *l = l_new(100, l_fval);
@@ -1065,14 +1066,16 @@ CMC_CREATE_UNIT(ListIter, true, {
#ifdef CMC_TEST_MAIN
int main(void)
{
int result = List() + ListIter();
int result = CMCList() + CMCListIter();
printf(" +---------------------------------------------------------------+");
printf("\n");
printf(" | List Suit : %-49s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" | CMCList Suit : %-49s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" +---------------------------------------------------------------+");
printf("\n\n\n");
return result;
}
#endif
#endif /* CMC_TESTS_UNT_CMC_LIST_H */
@@ -1,14 +1,15 @@
#include "utl.c"
#include "utl/assert.h"
#include "utl/test.h"
#ifndef CMC_TESTS_UNT_CMC_QUEUE_H
#define CMC_TESTS_UNT_CMC_QUEUE_H
#include "../src/queue.c"
#include "../utl.h"
#include "cmc/queue.h"
struct queue_fval *q_fval = &(struct queue_fval){
.cmp = cmc_size_cmp, .cpy = NULL, .str = cmc_size_str, .free = NULL, .hash = cmc_size_hash, .pri = cmc_size_cmp
};
CMC_CREATE_UNIT(Queue, true, {
CMC_CREATE_UNIT(CMCQueue, true, {
CMC_CREATE_TEST(new, {
struct queue *q = q_new(1000000, q_fval);
@@ -538,7 +539,7 @@ CMC_CREATE_UNIT(Queue, true, {
});
});
CMC_CREATE_UNIT(QueueIter, true, {
CMC_CREATE_UNIT(CMCQueueIter, true, {
CMC_CREATE_TEST(PFX##_iter_start(), {
struct queue *q = q_new(100, q_fval);
@@ -951,14 +952,16 @@ CMC_CREATE_UNIT(QueueIter, true, {
#ifdef CMC_TEST_MAIN
int main(void)
{
int result = Queue() + QueueIter();
int result = CMCQueue() + CMCQueueIter();
printf(" +---------------------------------------------------------------+");
printf("\n");
printf(" | Queue Suit : %-48s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" | CMCQueue Suit : %-48s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" +---------------------------------------------------------------+");
printf("\n\n\n");
return result;
}
#endif
#endif /* CMC_TESTS_UNT_CMC_QUEUE_H */
@@ -1,14 +1,15 @@
#include "utl.c"
#include "utl/assert.h"
#include "utl/test.h"
#ifndef CMC_TESTS_UNT_CMC_SORTEDLIST_H
#define CMC_TESTS_UNT_CMC_SORTEDLIST_H
#include "../src/sortedlist.c"
#include "../utl.h"
#include "cmc/sortedlist.h"
struct sortedlist_fval *sl_fval = &(struct sortedlist_fval){
.cmp = cmc_size_cmp, .cpy = NULL, .str = cmc_size_str, .free = NULL, .hash = cmc_size_hash, .pri = cmc_size_cmp
};
CMC_CREATE_UNIT(SortedList, true, {
CMC_CREATE_UNIT(CMCSortedList, true, {
CMC_CREATE_TEST(new, {
struct sortedlist *sl = sl_new(1000000, sl_fval);
@@ -308,7 +309,7 @@ CMC_CREATE_UNIT(SortedList, true, {
});
});
CMC_CREATE_UNIT(SortedListIter, true, {
CMC_CREATE_UNIT(CMCSortedListIter, true, {
CMC_CREATE_TEST(PFX##_iter_start(), {
struct sortedlist *sl = sl_new(100, sl_fval);
@@ -698,14 +699,16 @@ CMC_CREATE_UNIT(SortedListIter, true, {
#ifdef CMC_TEST_MAIN
int main(void)
{
int result = SortedList() + SortedListIter();
int result = CMCSortedList() + CMCSortedListIter();
printf(" +---------------------------------------------------------------+");
printf("\n");
printf(" | SortedList Suit : %-43s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" | CMCSortedList Suit : %-43s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" +---------------------------------------------------------------+");
printf("\n\n\n");
return result;
}
#endif
#endif /* CMC_TESTS_UNT_CMC_SORTEDLIST_H */
@@ -1,14 +1,15 @@
#include "utl.c"
#include "utl/assert.h"
#include "utl/test.h"
#ifndef CMC_TESTS_UNT_CMC_STACK_H
#define CMC_TESTS_UNT_CMC_STACK_H
#include "../src/stack.c"
#include "../utl.h"
#include "cmc/stack.h"
struct stack_fval *s_fval = &(struct stack_fval){
.cmp = cmc_size_cmp, .cpy = NULL, .str = cmc_size_str, .free = NULL, .hash = cmc_size_hash, .pri = cmc_size_cmp
};
CMC_CREATE_UNIT(Stack, true, {
CMC_CREATE_UNIT(CMCStack, true, {
CMC_CREATE_TEST(new, {
struct stack *s = s_new(1000000, s_fval);
@@ -402,7 +403,7 @@ CMC_CREATE_UNIT(Stack, true, {
});
});
CMC_CREATE_UNIT(StackIter, true, {
CMC_CREATE_UNIT(CMCStackIter, true, {
CMC_CREATE_TEST(PFX##_iter_start(), {
struct stack *s = s_new(100, s_fval);
@@ -833,14 +834,16 @@ CMC_CREATE_UNIT(StackIter, true, {
#ifdef CMC_TEST_MAIN
int main(void)
{
int result = Stack() + StackIter();
int result = CMCStack() + CMCStackIter();
printf(" +---------------------------------------------------------------+");
printf("\n");
printf(" | Stack Suit : %-48s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" | CMCStack Suit : %-48s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" +---------------------------------------------------------------+");
printf("\n\n\n");
return result;
}
#endif
#endif /* CMC_TESTS_UNT_CMC_STACK_H */
@@ -1,8 +1,9 @@
#include "utl.c"
#include "utl/assert.h"
#include "utl/test.h"
#ifndef CMC_TESTS_UNT_CMC_TREEMAP_H
#define CMC_TESTS_UNT_CMC_TREEMAP_H
#include "../src/treemap.c"
#include "../utl.h"
#include "cmc/treemap.h"
struct treemap_fkey *tm_fkey = &(struct treemap_fkey){
.cmp = cmc_size_cmp, .cpy = NULL, .str = cmc_size_str, .free = NULL, .hash = cmc_size_hash, .pri = cmc_size_cmp
@@ -12,7 +13,7 @@ struct treemap_fval *tm_fval = &(struct treemap_fval){
.cmp = cmc_size_cmp, .cpy = NULL, .str = cmc_size_str, .free = NULL, .hash = cmc_size_hash, .pri = cmc_size_cmp
};
CMC_CREATE_UNIT(TreeMap, true, {
CMC_CREATE_UNIT(CMCTreeMap, true, {
CMC_CREATE_TEST(new, {
struct treemap *map = tm_new(tm_fkey, tm_fval);
@@ -207,7 +208,7 @@ CMC_CREATE_UNIT(TreeMap, true, {
});
});
CMC_CREATE_UNIT(TreeMapIter, true, {
CMC_CREATE_UNIT(CMCTreeMapIter, true, {
CMC_CREATE_TEST(PFX##_iter_start(), {
struct treemap *map = tm_new(tm_fkey, tm_fval);
@@ -651,14 +652,16 @@ CMC_CREATE_UNIT(TreeMapIter, true, {
#ifdef CMC_TEST_MAIN
int main(void)
{
int result = TreeMap() + TreeMapIter();
int result = CMCTreeMap() + CMCTreeMapIter();
printf(" +---------------------------------------------------------------+");
printf("\n");
printf(" | TreeMap Suit : %-46s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" | CMCTreeMap Suit : %-46s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" +---------------------------------------------------------------+");
printf("\n\n\n");
return result;
}
#endif
#endif /* CMC_TESTS_UNT_CMC_TREEMAP_H */
@@ -1,14 +1,15 @@
#include "utl.c"
#include "utl/assert.h"
#include "utl/test.h"
#ifndef CMC_TESTS_UNT_CMC_TREESET_H
#define CMC_TESTS_UNT_CMC_TREESET_H
#include "../src/treeset.c"
#include "../utl.h"
#include "cmc/treeset.h"
struct treeset_fval *ts_fval = &(struct treeset_fval){
.cmp = cmc_size_cmp, .cpy = NULL, .str = cmc_size_str, .free = NULL, .hash = cmc_size_hash, .pri = cmc_size_cmp
};
CMC_CREATE_UNIT(TreeSet, true, {
CMC_CREATE_UNIT(CMCTreeSet, true, {
CMC_CREATE_TEST(new, {
struct treeset *set = ts_new(ts_fval);
@@ -162,7 +163,7 @@ CMC_CREATE_UNIT(TreeSet, true, {
});
});
CMC_CREATE_UNIT(TreeSetIter, true, {
CMC_CREATE_UNIT(CMCTreeSetIter, true, {
CMC_CREATE_TEST(PFX##_iter_start(), {
struct treeset *set = ts_new(ts_fval);
@@ -569,14 +570,16 @@ CMC_CREATE_UNIT(TreeSetIter, true, {
#ifdef CMC_TEST_MAIN
int main(void)
{
int result = TreeSet() + TreeSetIter();
int result = CMCTreeSet() + CMCTreeSetIter();
printf(" +---------------------------------------------------------------+");
printf("\n");
printf(" | TreeSet Suit : %-46s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" | CMCTreeSet Suit : %-46s |\n", result == 0 ? "PASSED" : "FAILED");
printf(" +---------------------------------------------------------------+");
printf("\n\n\n");
return result;
}
#endif
#endif /* CMC_TESTS_UNT_CMC_TREESET_H */
+6 -3
View File
@@ -1,13 +1,16 @@
/* Utility file to be included in the unit tests */
#ifndef CMC_UNIT_TEST_UTL__
#define CMC_UNIT_TEST_UTL__
#ifndef CMC_TESTS_UTL
#define CMC_TESTS_UTL
#include <inttypes.h>
#include <stdbool.h>
#include <stdlib.h>
#include "cor/hashtable.h"
#include "utl/assert.h"
#include "utl/foreach.h"
#include "utl/futils.h"
#include "utl/test.h"
size_t numhash(size_t a)
{
@@ -165,4 +168,4 @@ struct cmc_callbacks *callbacks = &(struct cmc_callbacks){ .create = callback_cr
.delete = callback_delete,
.resize = callback_resize };
#endif /* CMC_UNIT_TEST_UTL__ */
#endif /* CMC_TESTS_UTL */
@@ -1,25 +1,24 @@
#include "utl.c"
#include "utl/assert.h"
#include "utl/test.h"
#ifndef CMC_TESTS_UNT_UTL_FOREACH_H
#define CMC_TESTS_UNT_UTL_FOREACH_H
#include "utl/foreach.h"
#include "../utl.h"
#include "../src/bitset.c"
#include "../src/deque.c"
#include "../src/hashbidimap.c"
#include "../src/hashmap.c"
#include "../src/hashmultimap.c"
#include "../src/hashmultiset.c"
#include "../src/hashset.c"
#include "../src/heap.c"
#include "../src/intervalheap.c"
#include "../src/linkedlist.c"
#include "../src/list.c"
#include "../src/queue.c"
#include "../src/sortedlist.c"
#include "../src/stack.c"
#include "../src/treemap.c"
#include "../src/treeset.c"
#include "cmc/bitset.h"
#include "cmc/deque.h"
#include "cmc/hashbidimap.h"
#include "cmc/hashmap.h"
#include "cmc/hashmultimap.h"
#include "cmc/hashmultiset.h"
#include "cmc/hashset.h"
#include "cmc/heap.h"
#include "cmc/intervalheap.h"
#include "cmc/linkedlist.h"
#include "cmc/list.h"
#include "cmc/queue.h"
#include "cmc/sortedlist.h"
#include "cmc/stack.h"
#include "cmc/treemap.h"
#include "cmc/treeset.h"
CMC_CREATE_UNIT(ForEach, true, {
// CMC_CREATE_TEST(CMC<BitSet>, {
@@ -505,3 +504,5 @@ int main(void)
return result;
}
#endif
#endif /* CMC_TESTS_UNT_UTL_FOREACH_H */