Add core.cpp, testing changes
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
#include "../core_library/core.c"
|
||||
|
||||
void TestBootstrapArenaClear() {
|
||||
MA_Arena *arena = MA_Bootstrap();
|
||||
IO_Assert(arena->base_len != 0);
|
||||
@@ -29,36 +27,6 @@ void TestBootstrapArenaClear() {
|
||||
((char *)arena->memory.data)[arena->len - 1] = 0;
|
||||
}
|
||||
|
||||
void TestScratch() {
|
||||
MA_Arena *scratch_arena_test = NULL;
|
||||
{
|
||||
MA_Scratch scratch;
|
||||
IO_Assert(scratch.checkpoint.arena->len == 0);
|
||||
IO_Assert(scratch.checkpoint.arena->memory.data == NULL);
|
||||
int *a = MA_PushStruct(scratch, int);
|
||||
IO_Assert(scratch.checkpoint.arena->memory.data);
|
||||
IO_Assert(scratch.checkpoint.arena->len == sizeof(int));
|
||||
IO_Assert(scratch.checkpoint.arena);
|
||||
scratch_arena_test = scratch.checkpoint.arena;
|
||||
|
||||
int b = 10;
|
||||
IO_Assert(MA_IsPointerInside(scratch, a));
|
||||
IO_Assert(!MA_IsPointerInside(scratch, &b));
|
||||
}
|
||||
|
||||
{
|
||||
MA_Scratch scratch;
|
||||
IO_Assert(scratch_arena_test == scratch.checkpoint.arena);
|
||||
IO_Assert(scratch.checkpoint.arena->len == 0);
|
||||
|
||||
MA_Scratch scratch2(scratch.checkpoint);
|
||||
IO_Assert(scratch.checkpoint.arena != scratch2.checkpoint.arena);
|
||||
|
||||
MA_Scratch scratch3(scratch.checkpoint, scratch2.checkpoint);
|
||||
IO_Assert(scratch3.checkpoint.arena != scratch2.checkpoint.arena);
|
||||
}
|
||||
}
|
||||
|
||||
void TestBuffer() {
|
||||
char buffer[1024];
|
||||
MA_Arena buffer_arena = MA_MakeFromBuffer(buffer, 1024);
|
||||
@@ -98,12 +66,3 @@ void TestBootstrapExclusive() {
|
||||
For(v) IO_Assert(it == i++);
|
||||
v.dealloc();
|
||||
}
|
||||
|
||||
int main() {
|
||||
TestScratch();
|
||||
TestBuffer();
|
||||
TestCreateAllocate();
|
||||
TestBootstrap();
|
||||
TestBootstrapExclusive();
|
||||
TestBootstrapArenaClear();
|
||||
}
|
||||
Reference in New Issue
Block a user