Move tests to test.cpp; build: make test.out
This commit is contained in:
parent
90ab3166a2
commit
41301ece28
14
main.cpp
14
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);
|
||||
}
|
||||
}
|
||||
|
38
test.cpp
Normal file
38
test.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user