Fixing tests and added linkedqueue tests

This commit is contained in:
Leonardo committed 2019-07-10 17:26:31 -03:00
1 parent 7ecb2e90fd
commit 9eb8d5f682
15 files changed
+331 -57

No files matched your search

+5 -5
View File
@@ -6,7 +6,7 @@
CMC_CREATE_UNIT(heap_test, true, {
CMC_CREATE_TEST(new, {
heap *h = h_new(1000000, MaxHeap, cmp);
heap *h = h_new(1000000, cmc_max_heap, cmp);
cmc_assert_not_equals(ptr, NULL, h);
@@ -22,7 +22,7 @@ CMC_CREATE_UNIT(heap_test, true, {
});
CMC_CREATE_TEST(new[edge_case:capacity = 0], {
heap *h = h_new(0, MaxHeap, cmp);
heap *h = h_new(0, cmc_max_heap, cmp);
cmc_assert_equals(ptr, NULL, h);
@@ -30,7 +30,7 @@ CMC_CREATE_UNIT(heap_test, true, {
});
CMC_CREATE_TEST(new[edge_case:capacity = UINT64_MAX], {
heap *h = h_new(UINT64_MAX, MaxHeap, cmp);
heap *h = h_new(UINT64_MAX, cmc_max_heap, cmp);
cmc_assert_equals(ptr, NULL, h);
@@ -38,7 +38,7 @@ CMC_CREATE_UNIT(heap_test, true, {
});
CMC_CREATE_TEST(clear[count capacity], {
heap *h = h_new(100, MaxHeap, cmp);
heap *h = h_new(100, cmc_max_heap, cmp);
cmc_assert_not_equals(ptr, NULL, h);
@@ -58,7 +58,7 @@ CMC_CREATE_UNIT(heap_test, true, {
});
CMC_CREATE_TEST(buffer_growth[edge_case:capacity = 1], {
heap *h = h_new(1, MaxHeap, cmp);
heap *h = h_new(1, cmc_max_heap, cmp);
cmc_assert_not_equals(ptr, NULL, h);
+41
View File
@@ -0,0 +1,41 @@
#include "utl/assert.h"
#include "utl/test.h"
#include "../src/linkedqueue.c"
CMC_CREATE_UNIT(linkedqueue_test, true, {
CMC_CREATE_TEST(new, {
linkedqueue *q = lq_new();
cmc_assert_not_equals(ptr, NULL, q);
bool passed = q->count == 0 && !q->head && !q->tail;
cmc_assert_equals(size_t, 0, lq_count(q));
cmc_assert_equals(ptr, NULL, q->head);
cmc_assert_equals(ptr, NULL, q->tail);
CMC_TEST_PASS_ELSE_FAIL(passed);
lq_free(q);
});
CMC_CREATE_TEST(clear[count], {
linkedqueue *q = lq_new();
cmc_assert_not_equals(ptr, NULL, q);
for (size_t i = 0; i < 50; i++)
lq_enqueue(q, i);
cmc_assert_equals(size_t, 50, lq_count(q));
lq_clear(q);
cmc_assert_equals(size_t, 0, lq_count(q));
CMC_TEST_PASS_ELSE_FAIL(lq_count(q) == 0);
lq_free(q);
});
});