diff --git a/main.cpp b/main.cpp index 33f5773..43dc336 100644 --- a/main.cpp +++ b/main.cpp @@ -12,18 +12,6 @@ list freelist = {0}, list1 = {0}, list2 = {0}; int main (int argc, char* argv[]) { // initialize the freelist list_init(&freelist, memory, N); - - // print the list + // print the freelist list_print(&freelist); - list_print(&list1); - - // move a block - block* b; - while (b = list_unlink(&freelist)) { - list_link(&list1, b); - // print the list - std::printf("\n"); - list_print(&freelist); - list_print(&list1); - } } diff --git a/test.cpp b/test.cpp new file mode 100644 index 0000000..917695e --- /dev/null +++ b/test.cpp @@ -0,0 +1,38 @@ +#include +#include +#include "list.hpp" + +#define N 0x8 + +int movement_test (); + +int main(int argc, char *argv[]) { + movement_test(); +} + +int movement_test () { + + // Create all of memory + block memory[N] = {0}; + // create the three lists + list freelist = {0}, list1 = {0}; + // initialize the freelist + list_init(&freelist, memory, N); + + // print the lists + std::printf("Lists:\n"); + list_print(&freelist); + list_print(&list1); + + // move a block + block *b; + while (b = list_unlink(&freelist)) + { + list_link(&list1, b); + } + // print the lists again (should be reversed order) + std::printf("Lists, again:\n"); + list_print(&freelist); + list_print(&list1); + return 1; +}