Adding functions table to treemap and treeset and some fixes to to_string

This commit is contained in:
Leonardo committed 2020-02-11 15:58:39 -03:00
1 parent 7efc0e26e0
commit 5ed65668e0
7 files changed
+1125 -1012

No files matched your search

+21 -5
View File
@@ -7,17 +7,33 @@
CMC_GENERATE_TREEMAP(tm, treemap, size_t, size_t)
struct treemap_ftab_key *tm_ftab_key =
&(struct treemap_ftab_key){ .cmp = cmp,
.cpy = copy,
.str = str,
.free = custom_free,
.hash = hash,
.pri = pri };
struct treemap_ftab_val *tm_ftab_val =
&(struct treemap_ftab_val){ .cmp = cmp,
.cpy = copy,
.str = str,
.free = custom_free,
.hash = hash,
.pri = pri };
CMC_CREATE_UNIT(treemap_test, true, {
CMC_CREATE_TEST(new, {
struct treemap *map = tm_new(cmp);
struct treemap *map = tm_new(tm_ftab_key, tm_ftab_val);
cmc_assert_not_equals(ptr, NULL, map);
tm_free(map, NULL);
tm_free(map);
});
CMC_CREATE_TEST(clear[count], {
struct treemap *map = tm_new(cmp);
struct treemap *map = tm_new(tm_ftab_key, tm_ftab_val);
cmc_assert_not_equals(ptr, NULL, map);
@@ -26,11 +42,11 @@ CMC_CREATE_UNIT(treemap_test, true, {
cmc_assert_equals(size_t, 50, tm_count(map));
tm_clear(map, NULL);
tm_clear(map);
cmc_assert_equals(size_t, 0, tm_count(map));
cmc_assert_equals(ptr, NULL, map->root);
tm_free(map, NULL);
tm_free(map);
});
});
+13 -5
View File
@@ -7,17 +7,25 @@
CMC_GENERATE_TREESET(ts, treeset, size_t)
struct treeset_ftab_val *ts_ftab_val =
&(struct treeset_ftab_val){ .cmp = cmp,
.cpy = copy,
.str = str,
.free = custom_free,
.hash = hash,
.pri = pri };
CMC_CREATE_UNIT(treeset_test, true, {
CMC_CREATE_TEST(new, {
struct treeset *set = ts_new(cmp);
struct treeset *set = ts_new(ts_ftab_val);
cmc_assert_not_equals(ptr, NULL, set);
ts_free(set, NULL);
ts_free(set);
});
CMC_CREATE_TEST(clear[count], {
struct treeset *set = ts_new(cmp);
struct treeset *set = ts_new(ts_ftab_val);
cmc_assert_not_equals(ptr, NULL, set);
@@ -26,11 +34,11 @@ CMC_CREATE_UNIT(treeset_test, true, {
cmc_assert_equals(size_t, 50, ts_count(set));
ts_clear(set, NULL);
ts_clear(set);
cmc_assert_equals(size_t, 0, ts_count(set));
cmc_assert_equals(ptr, NULL, set->root);
ts_free(set, NULL);
ts_free(set);
});
});