Skip to content
This repository has been archived by the owner on Jun 6, 2020. It is now read-only.

Commit

Permalink
Change structure and cleanup list test
Browse files Browse the repository at this point in the history
  • Loading branch information
SimoneStefani committed Jan 14, 2018
1 parent fcbdf7c commit fd52a03
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,6 @@ dkms.conf
output/

# End of https://www.gitignore.io/api/c

# CSV output
*.csv
1 change: 0 additions & 1 deletion samples/triangular_exec.csv

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
#include <assert.h>
#include <stdio.h>

#include "./doubly_linked_list_pq.h"
#include "./linked_list_pq.h"

/*
Test if the linked list can correctly enqueue a new
element and hence grows in size of one.
*/
void test_enqueue_list() {
// setup
reset_queue();
Expand All @@ -13,10 +17,14 @@ void test_enqueue_list() {
enqueue(1.0);
assert(traversal_count() == 1);

// cleanup
// teardown
reset_queue();
}

/*
Test if the linked list can correctly dequeue an element
and hence decrease in size of one.
*/
void test_dequeue_list() {
// setup
reset_queue();
Expand All @@ -27,10 +35,14 @@ void test_dequeue_list() {
dequeue();
assert(traversal_count() == 0);

// cleanup
// teardown
reset_queue();
}

/*
Test if the linked list can be correctly reset, i.e. all
elements are removed.
*/
void test_reset_list() {
// setup
reset_queue();
Expand All @@ -42,10 +54,14 @@ void test_reset_list() {
reset_queue();
assert(traversal_count() == 0);

// cleanup
// teardown
reset_queue();
}

/*
Test if the dequeue() methods returns the smallest element
in the list, i.e. the element with highest priority.
*/
void test_dequeue_smallest_element() {
// setup
reset_queue();
Expand All @@ -57,10 +73,17 @@ void test_dequeue_smallest_element() {
// test
assert(dequeue() == 1.0);

// cleanup
// teardown
reset_queue();
}

/*
Test if the list maintains a correct internal order of
the elements based on priority. In such case, in a
sequence of dequeue operations, every dequeued element
should be smaller (i.e. has higher priority) than the
element previously dequeued.
*/
void test_queue_maintains_internal_order() {
// setup
reset_queue();
Expand All @@ -77,10 +100,14 @@ void test_queue_maintains_internal_order() {
pred = current;
}

// cleanup
// teardown
reset_queue();
}

/*
Run all the tests. If any assertion fails it will throw
an error and abort the program.
*/
int main() {
printf("Testing 'test_enqueue_list'... ");
test_enqueue_list();
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit fd52a03

Please sign in to comment.