Callbacks redone
This commit is contained in:
1 parent
a46ba1f255
commit
015d14216f
81 files changed
+378
-1641
No files matched your search
@@ -338,72 +338,6 @@ CMC_CREATE_UNIT(CMCStack, true, {
|
||||
s_free(s);
|
||||
s_free(s2);
|
||||
});
|
||||
|
||||
CMC_CREATE_TEST(callbacks, {
|
||||
struct stack *s = s_new_custom(100, s_fval, NULL, callbacks);
|
||||
|
||||
cmc_assert_not_equals(ptr, NULL, s);
|
||||
|
||||
total_create = 0;
|
||||
total_read = 0;
|
||||
total_update = 0;
|
||||
total_delete = 0;
|
||||
total_resize = 0;
|
||||
|
||||
cmc_assert(s_push(s, 10));
|
||||
cmc_assert_equals(int32_t, 1, total_create);
|
||||
|
||||
cmc_assert(s_pop(s));
|
||||
cmc_assert_equals(int32_t, 1, total_delete);
|
||||
|
||||
cmc_assert(s_push(s, 1));
|
||||
cmc_assert_equals(int32_t, 2, total_create);
|
||||
|
||||
cmc_assert_equals(size_t, 1, s_top(s));
|
||||
cmc_assert_equals(int32_t, 1, total_read);
|
||||
|
||||
cmc_assert(s_contains(s, 1));
|
||||
cmc_assert_equals(int32_t, 2, total_read);
|
||||
|
||||
cmc_assert(s_resize(s, 1000));
|
||||
cmc_assert_equals(int32_t, 1, total_resize);
|
||||
|
||||
cmc_assert(s_resize(s, 10));
|
||||
cmc_assert_equals(int32_t, 2, total_resize);
|
||||
|
||||
cmc_assert_equals(int32_t, 2, total_create);
|
||||
cmc_assert_equals(int32_t, 2, total_read);
|
||||
cmc_assert_equals(int32_t, 0, total_update);
|
||||
cmc_assert_equals(int32_t, 1, total_delete);
|
||||
cmc_assert_equals(int32_t, 2, total_resize);
|
||||
|
||||
s_customize(s, NULL, NULL);
|
||||
|
||||
s_clear(s);
|
||||
cmc_assert(s_push(s, 10));
|
||||
cmc_assert(s_pop(s));
|
||||
cmc_assert(s_push(s, 1));
|
||||
cmc_assert_equals(size_t, 1, s_top(s));
|
||||
cmc_assert(s_contains(s, 1));
|
||||
cmc_assert(s_resize(s, 1000));
|
||||
cmc_assert(s_resize(s, 10));
|
||||
|
||||
cmc_assert_equals(int32_t, 2, total_create);
|
||||
cmc_assert_equals(int32_t, 2, total_read);
|
||||
cmc_assert_equals(int32_t, 0, total_update);
|
||||
cmc_assert_equals(int32_t, 1, total_delete);
|
||||
cmc_assert_equals(int32_t, 2, total_resize);
|
||||
|
||||
cmc_assert_equals(ptr, NULL, s->callbacks);
|
||||
|
||||
s_free(s);
|
||||
|
||||
total_create = 0;
|
||||
total_read = 0;
|
||||
total_update = 0;
|
||||
total_delete = 0;
|
||||
total_resize = 0;
|
||||
});
|
||||
});
|
||||
|
||||
CMC_CREATE_UNIT(CMCStackIter, true, {
|
||||
|
||||
Reference in new issue
Block a user