Move tests to test.cpp; build: make test.out

This commit is contained in:
John 2022-04-03 11:48:24 -05:00
parent 90ab3166a2
commit 41301ece28
2 changed files with 39 additions and 13 deletions

View File

@ -12,18 +12,6 @@ list freelist = {0}, list1 = {0}, list2 = {0};
int main (int argc, char* argv[]) { int main (int argc, char* argv[]) {
// initialize the freelist // initialize the freelist
list_init(&freelist, memory, N); list_init(&freelist, memory, N);
// print the freelist
// print the list
list_print(&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);
}
} }

38
test.cpp Normal file
View File

@ -0,0 +1,38 @@
#include <cstdint>
#include <cstdio>
#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;
}