summaryrefslogtreecommitdiff
path: root/src/01/01a/priority_queue_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/01/01a/priority_queue_test.c')
-rw-r--r--src/01/01a/priority_queue_test.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/01/01a/priority_queue_test.c b/src/01/01a/priority_queue_test.c
index 4f4824e..abe30c5 100644
--- a/src/01/01a/priority_queue_test.c
+++ b/src/01/01a/priority_queue_test.c
@@ -12,16 +12,6 @@ Implement the methods of the priority queue interface using a singly-linked list
Analyze the running time of the `add(x)` and `deletMin()` operations based on this implementation.
*/
-static void inspect(PriorityQueue *queue) {
- Node *tmp = queue->head;
-
- printf("Inspecting...\n");
- while(tmp) {
- printf("%d\n", tmp->data);
- tmp = tmp->next;
- }
-}
-
Describe(PriorityQueue);
BeforeEach(PriorityQueue){ }
AfterEach(PriorityQueue){ }
@@ -94,6 +84,19 @@ Ensure(PriorityQueue, when_removing_the_last_node_it_decrements_the_count_correc
destroy(queue);
}
+Ensure(PriorityQueue, when_adding_random_values_with_random_priority_it_returns_the_minimum_priority_value_correctly) {
+ PriorityQueue *queue = initialize();
+
+ for (int i = 0; i < 10; i++)
+ add(queue, rand() % 10, rand() % 1000);
+
+ while (size(queue) > 0)
+ delete_min(queue);
+
+ assert_that(size(queue), is_equal_to(0));
+ destroy(queue);
+}
+
TestSuite *priority_queue_tests() {
TestSuite *suite = create_test_suite();