Compare commits
No commits in common. "25964d9a3c450619997d6bd2fb6575bf1a0eb1d8" and "2c556e12f12a0470de52b669b87f851c2c0c7d9a" have entirely different histories.
25964d9a3c
...
2c556e12f1
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,8 +3,6 @@
|
|||||||
test
|
test
|
||||||
test.*
|
test.*
|
||||||
*.dSYM
|
*.dSYM
|
||||||
*.pdb
|
|
||||||
*.obj
|
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
libwapp-build
|
libwapp-build
|
||||||
libwapp.so
|
libwapp.so
|
||||||
|
25
build.ps1
25
build.ps1
@ -3,16 +3,11 @@ Param(
|
|||||||
)
|
)
|
||||||
|
|
||||||
$Compiler = "cl.exe"
|
$Compiler = "cl.exe"
|
||||||
|
|
||||||
$GeneralFlags = "/Wall /WX /wd4996"
|
$GeneralFlags = "/Wall /WX /wd4996"
|
||||||
$LibraryFlags = "/LD"
|
$LibraryFlags = "/LD"
|
||||||
|
|
||||||
$IncludeDirs = Get-ChildItem -Path src -Recurse -Directory -ErrorAction SilentlyContinue -Force | %{$("/I " + '"' + $_.FullName + '"')}
|
$IncludeDirs = Get-ChildItem -Path src -Recurse -Directory -ErrorAction SilentlyContinue -Force | %{$("/I " + '"' + $_.FullName + '"')}
|
||||||
$SrcFiles = Get-ChildItem -Path src -Recurse -Filter *.c -ErrorAction SilentlyContinue -Force | %{$('"' + $_.FullName + '"')}
|
$SrcFiles = Get-ChildItem -Path src -Recurse -Filter *.c -ErrorAction SilentlyContinue -Force | %{$('"' + $_.FullName + '"')}
|
||||||
|
|
||||||
$TestIncludeDirs = Get-ChildItem -Path tests -Recurse -Directory -ErrorAction SilentlyContinue -Force | %{$("/I " + '"' + $_.FullName + '"')}
|
|
||||||
$TestSrcFiles = Get-ChildItem -Path tests -Recurse -Filter *.c -ErrorAction SilentlyContinue -Force | %{$('"' + $_.FullName + '"')}
|
|
||||||
|
|
||||||
If ($Release -eq $True) {
|
If ($Release -eq $True) {
|
||||||
$GeneralFlags += " /O2 /Og"
|
$GeneralFlags += " /O2 /Og"
|
||||||
$BuildType = "release"
|
$BuildType = "release"
|
||||||
@ -24,35 +19,15 @@ If ($Release -eq $True) {
|
|||||||
$BuildDir = "./libwapp-build/windows-$BuildType"
|
$BuildDir = "./libwapp-build/windows-$BuildType"
|
||||||
$ObjDir = "$BuildDir/objects"
|
$ObjDir = "$BuildDir/objects"
|
||||||
$OutDir = "$BuildDir/output"
|
$OutDir = "$BuildDir/output"
|
||||||
$TestsDir = "$BuildDir/tests"
|
|
||||||
|
|
||||||
$OutBasename = "libwapp"
|
$OutBasename = "libwapp"
|
||||||
$Objects = "/Fo:$ObjDir/"
|
$Objects = "/Fo:$ObjDir/"
|
||||||
$Outputs = "/Fd:$OutDir/$OutBasename /Fe:$OutDir/$OutBasename"
|
$Outputs = "/Fd:$OutDir/$OutBasename /Fe:$OutDir/$OutBasename"
|
||||||
|
|
||||||
$TestOutBasename = "wapptest"
|
|
||||||
$TestOutputs = "/Fo:$TestsDir/ /Fe:$TestsDir/$TestOutBasename"
|
|
||||||
|
|
||||||
If (Test-Path $BuildDir) {
|
If (Test-Path $BuildDir) {
|
||||||
Remove-Item $BuildDir -Recurse -Force
|
Remove-Item $BuildDir -Recurse -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdir -p $ObjDir > $null
|
mkdir -p $ObjDir > $null
|
||||||
mkdir -p $OutDir > $null
|
mkdir -p $OutDir > $null
|
||||||
mkdir -p $TestsDir > $null
|
|
||||||
|
|
||||||
# Build and run tests
|
|
||||||
Invoke-Expression "$Compiler $GeneralFlags $IncludeDirs $TestIncludeDirs $SrcFiles $TestSrcFiles $TestOutputs" -ErrorAction Stop
|
|
||||||
|
|
||||||
Invoke-Expression "$TestsDir/$TestOutBasename.exe"
|
|
||||||
$Status = $LASTEXITCODE
|
|
||||||
|
|
||||||
Remove-Item $TestsDir -Recurse -Force
|
|
||||||
|
|
||||||
If ($Status -ne 0) {
|
|
||||||
Write-Error "Tests failed"
|
|
||||||
Exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Build library
|
|
||||||
Invoke-Expression "$Compiler $GeneralFlags $LibraryFlags $IncludeDirs $SrcFiles $Objects $Outputs"
|
Invoke-Expression "$Compiler $GeneralFlags $LibraryFlags $IncludeDirs $SrcFiles $Objects $Outputs"
|
||||||
|
5
compile
5
compile
@ -64,3 +64,8 @@ fi
|
|||||||
|
|
||||||
# Compile library
|
# Compile library
|
||||||
(set -x ; $CC $CFLAGS $LIBFLAGS $INCLUDE $SRC -o $OUT)
|
(set -x ; $CC $CFLAGS $LIBFLAGS $INCLUDE $SRC -o $OUT)
|
||||||
|
|
||||||
|
# Compile test.c if it exists
|
||||||
|
if [[ -f ./test.c ]]; then
|
||||||
|
(set -x ; $CC $CFLAGS $INCLUDE $SRC ./test.c -o test)
|
||||||
|
fi
|
||||||
|
@ -80,15 +80,14 @@ void *wapp_mem_arena_alloc_aligned(Arena *arena, u64 size, u64 alignment) {
|
|||||||
|
|
||||||
#ifdef WAPP_PLATFORM_WINDOWS
|
#ifdef WAPP_PLATFORM_WINDOWS
|
||||||
if (!(arena->committed)) {
|
if (!(arena->committed)) {
|
||||||
output = (u8 *)wapp_mem_util_alloc(
|
output = (u8 *)wapp_mem_util_alloc(output, size, WAPP_MEM_ACCESS_READ_WRITE,
|
||||||
alloc_start, (uptr)(arena->offset) - (uptr)(alloc_start),
|
WAPP_MEM_ALLOC_COMMIT,
|
||||||
WAPP_MEM_ACCESS_READ_WRITE, WAPP_MEM_ALLOC_COMMIT,
|
WAPP_MEM_INIT_UNINITIALISED);
|
||||||
WAPP_MEM_INIT_INITIALISED);
|
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
memset(output, 0, size);
|
|
||||||
#endif // ifdef WAPP_PLATFORM_WINDOWS
|
#endif // ifdef WAPP_PLATFORM_WINDOWS
|
||||||
|
|
||||||
|
memset(output, 0, size);
|
||||||
|
|
||||||
return (void *)output;
|
return (void *)output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ StringUpdate wapp_dstr_concat(String **dst, const char *src, Arena *arena) {
|
|||||||
#else
|
#else
|
||||||
char str[new_length + 1];
|
char str[new_length + 1];
|
||||||
memset(str, 0, new_length + 1);
|
memset(str, 0, new_length + 1);
|
||||||
#endif /* ifdef WAPP_PLATFORM_WINDOWS */
|
#endif
|
||||||
|
|
||||||
strncpy(str, (*dst)->buf, (*dst)->size);
|
strncpy(str, (*dst)->buf, (*dst)->size);
|
||||||
strncat(str, src, new_length + 1 - (*dst)->size);
|
strncat(str, src, new_length + 1 - (*dst)->size);
|
||||||
|
@ -1,101 +0,0 @@
|
|||||||
#include "termcolour.h"
|
|
||||||
#include "aliases.h"
|
|
||||||
#include "platform.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
internal void print_coloured_text(const TerminalColourist *colourist,
|
|
||||||
const char *text);
|
|
||||||
|
|
||||||
#ifdef WAPP_PLATFORM_WINDOWS
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#include <Windows.h>
|
|
||||||
|
|
||||||
internal WORD colours[COUNT_TERM_COLOUR] = {
|
|
||||||
[WAPP_TERM_COLOUR_FG_BLACK] = 0,
|
|
||||||
[WAPP_TERM_COLOUR_FG_RED] = FOREGROUND_RED,
|
|
||||||
[WAPP_TERM_COLOUR_FG_GREEN] = FOREGROUND_GREEN,
|
|
||||||
[WAPP_TERM_COLOUR_FG_BLUE] = FOREGROUND_BLUE,
|
|
||||||
[WAPP_TERM_COLOUR_FG_CYAN] = FOREGROUND_GREEN | FOREGROUND_BLUE,
|
|
||||||
[WAPP_TERM_COLOUR_FG_MAGENTA] = FOREGROUND_RED | FOREGROUND_BLUE,
|
|
||||||
[WAPP_TERM_COLOUR_FG_YELLOW] = FOREGROUND_RED | FOREGROUND_GREEN,
|
|
||||||
[WAPP_TERM_COLOUR_FG_WHITE] =
|
|
||||||
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE,
|
|
||||||
[WAPP_TERM_COLOUR_FG_BR_BLACK] = FOREGROUND_INTENSITY,
|
|
||||||
[WAPP_TERM_COLOUR_FG_BR_RED] = FOREGROUND_RED | FOREGROUND_INTENSITY,
|
|
||||||
[WAPP_TERM_COLOUR_FG_BR_GREEN] = FOREGROUND_GREEN | FOREGROUND_INTENSITY,
|
|
||||||
[WAPP_TERM_COLOUR_FG_BR_BLUE] = FOREGROUND_BLUE | FOREGROUND_INTENSITY,
|
|
||||||
[WAPP_TERM_COLOUR_FG_BR_CYAN] =
|
|
||||||
FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY,
|
|
||||||
[WAPP_TERM_COLOUR_FG_BR_MAGENTA] =
|
|
||||||
FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY,
|
|
||||||
[WAPP_TERM_COLOUR_FG_BR_YELLOW] =
|
|
||||||
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY,
|
|
||||||
[WAPP_TERM_COLOUR_FG_BR_WHITE] = FOREGROUND_RED | FOREGROUND_GREEN |
|
|
||||||
FOREGROUND_BLUE | FOREGROUND_INTENSITY,
|
|
||||||
};
|
|
||||||
#else
|
|
||||||
internal const char *colours[COUNT_TERM_COLOUR] = {
|
|
||||||
[WAPP_TERM_COLOUR_FG_BLACK] = "\033[30m",
|
|
||||||
[WAPP_TERM_COLOUR_FG_RED] = "\033[31m",
|
|
||||||
[WAPP_TERM_COLOUR_FG_GREEN] = "\033[32m",
|
|
||||||
[WAPP_TERM_COLOUR_FG_BLUE] = "\033[34m",
|
|
||||||
[WAPP_TERM_COLOUR_FG_CYAN] = "\033[36m",
|
|
||||||
[WAPP_TERM_COLOUR_FG_MAGENTA] = "\033[35m",
|
|
||||||
[WAPP_TERM_COLOUR_FG_YELLOW] = "\033[33m",
|
|
||||||
[WAPP_TERM_COLOUR_FG_WHITE] = "\033[37m",
|
|
||||||
[WAPP_TERM_COLOUR_FG_BR_BLACK] = "\033[90m",
|
|
||||||
[WAPP_TERM_COLOUR_FG_BR_RED] = "\033[91m",
|
|
||||||
[WAPP_TERM_COLOUR_FG_BR_GREEN] = "\033[92m",
|
|
||||||
[WAPP_TERM_COLOUR_FG_BR_BLUE] = "\033[94m",
|
|
||||||
[WAPP_TERM_COLOUR_FG_BR_CYAN] = "\033[96m",
|
|
||||||
[WAPP_TERM_COLOUR_FG_BR_MAGENTA] = "\033[95m",
|
|
||||||
[WAPP_TERM_COLOUR_FG_BR_YELLOW] = "\033[93m",
|
|
||||||
[WAPP_TERM_COLOUR_FG_BR_WHITE] = "\033[97m",
|
|
||||||
};
|
|
||||||
#endif /* ifdef WAPP_PLATFORM_WINDOWS */
|
|
||||||
|
|
||||||
TerminalColourist wapp_termcolour_get_colourist(void) {
|
|
||||||
TerminalColourist colourist;
|
|
||||||
|
|
||||||
#ifdef WAPP_PLATFORM_WINDOWS
|
|
||||||
// create handle
|
|
||||||
colourist.handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
||||||
|
|
||||||
// get console colour information
|
|
||||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
|
||||||
GetConsoleScreenBufferInfo(colourist.handle, &csbi);
|
|
||||||
colourist.default_colour = csbi.wAttributes;
|
|
||||||
#else
|
|
||||||
colourist.default_colour = "\033[0m";
|
|
||||||
#endif // ifdef WAPP_PLATFORM_WINDOWS
|
|
||||||
|
|
||||||
colourist.current_colour = colourist.default_colour;
|
|
||||||
|
|
||||||
return colourist;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wapp_termcolour_print_text(TerminalColourist *colourist, const char *text,
|
|
||||||
TerminalColour colour) {
|
|
||||||
if (colour < WAPP_TERM_COLOUR_FG_BLACK ||
|
|
||||||
colour > WAPP_TERM_COLOUR_FG_BR_WHITE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
colourist->current_colour = colours[colour];
|
|
||||||
print_coloured_text(colourist, text);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wapp_termcolour_clear_colour(TerminalColourist *colourist) {
|
|
||||||
colourist->current_colour = colourist->default_colour;
|
|
||||||
print_coloured_text(colourist, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void print_coloured_text(const TerminalColourist *colourist,
|
|
||||||
const char *text) {
|
|
||||||
#ifdef WAPP_PLATFORM_WINDOWS
|
|
||||||
SetConsoleTextAttribute(colourist->handle, colourist->current_colour);
|
|
||||||
printf("%s", text);
|
|
||||||
#else
|
|
||||||
printf("%s%s", colourist->current_colour, text);
|
|
||||||
#endif // ifdef WAPP_PLATFORM_WINDOWS
|
|
||||||
}
|
|
@ -1,56 +1,48 @@
|
|||||||
#ifndef TERM_COLOUR_H
|
#ifndef TERM_COLOUR_H
|
||||||
#define TERM_COLOUR_H
|
#define TERM_COLOUR_H
|
||||||
|
|
||||||
#include "aliases.h"
|
|
||||||
#include "misc_utils.h"
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
WAPP_TERM_COLOUR_FG_BLACK,
|
|
||||||
WAPP_TERM_COLOUR_FG_RED,
|
|
||||||
WAPP_TERM_COLOUR_FG_GREEN,
|
|
||||||
WAPP_TERM_COLOUR_FG_BLUE,
|
|
||||||
WAPP_TERM_COLOUR_FG_CYAN,
|
|
||||||
WAPP_TERM_COLOUR_FG_MAGENTA,
|
|
||||||
WAPP_TERM_COLOUR_FG_YELLOW,
|
|
||||||
WAPP_TERM_COLOUR_FG_WHITE,
|
|
||||||
WAPP_TERM_COLOUR_FG_BR_BLACK,
|
|
||||||
WAPP_TERM_COLOUR_FG_BR_RED,
|
|
||||||
WAPP_TERM_COLOUR_FG_BR_GREEN,
|
|
||||||
WAPP_TERM_COLOUR_FG_BR_BLUE,
|
|
||||||
WAPP_TERM_COLOUR_FG_BR_CYAN,
|
|
||||||
WAPP_TERM_COLOUR_FG_BR_MAGENTA,
|
|
||||||
WAPP_TERM_COLOUR_FG_BR_YELLOW,
|
|
||||||
WAPP_TERM_COLOUR_FG_BR_WHITE,
|
|
||||||
|
|
||||||
COUNT_TERM_COLOUR,
|
|
||||||
} TerminalColour;
|
|
||||||
|
|
||||||
typedef struct terminal_colourist TerminalColourist;
|
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#ifdef WAPP_PLATFORM_WINDOWS
|
#if defined(WAPP_PLATFORM_WINDOWS)
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define TERM_COLOUR_CLEAR ""
|
||||||
#include <Windows.h>
|
#define TERM_COLOUR_BOLD ""
|
||||||
#include <WinCon.h>
|
#define TERM_COLOUR_FG_BLACK ""
|
||||||
|
#define TERM_COLOUR_FG_RED ""
|
||||||
struct terminal_colourist {
|
#define TERM_COLOUR_FG_GREEN ""
|
||||||
HANDLE handle;
|
#define TERM_COLOUR_FG_YELLOW ""
|
||||||
WORD default_colour;
|
#define TERM_COLOUR_FG_BLUE ""
|
||||||
WORD current_colour;
|
#define TERM_COLOUR_FG_MAGENTA ""
|
||||||
wapp_misc_utils_padding_size(sizeof(HANDLE) + sizeof(WORD) + sizeof(WORD));
|
#define TERM_COLOUR_FG_CYAN ""
|
||||||
};
|
#define TERM_COLOUR_FG_WHITE ""
|
||||||
#else
|
#define TERM_COLOUR_FG_BR_BLACK ""
|
||||||
struct terminal_colourist {
|
#define TERM_COLOUR_FG_BR_RED ""
|
||||||
const char *default_colour;
|
#define TERM_COLOUR_FG_BR_GREEN ""
|
||||||
const char *current_colour;
|
#define TERM_COLOUR_FG_BR_YELLOW ""
|
||||||
};
|
#define TERM_COLOUR_FG_BR_BLUE ""
|
||||||
#endif // WAPP_PLATFORM_WINDOWS
|
#define TERM_COLOUR_FG_BR_MAGENTA ""
|
||||||
|
#define TERM_COLOUR_FG_BR_CYAN ""
|
||||||
|
#define TERM_COLOUR_FG_BR_WHITE ""
|
||||||
|
#elif defined(WAPP_PLATFORM_POSIX)
|
||||||
|
#define TERM_COLOUR_CLEAR "\033[0m"
|
||||||
|
#define TERM_COLOUR_BOLD "\033[1m"
|
||||||
|
#define TERM_COLOUR_FG_BLACK "\033[30m"
|
||||||
|
#define TERM_COLOUR_FG_RED "\033[31m"
|
||||||
|
#define TERM_COLOUR_FG_GREEN "\033[32m"
|
||||||
|
#define TERM_COLOUR_FG_YELLOW "\033[33m"
|
||||||
|
#define TERM_COLOUR_FG_BLUE "\033[34m"
|
||||||
|
#define TERM_COLOUR_FG_MAGENTA "\033[35m"
|
||||||
|
#define TERM_COLOUR_FG_CYAN "\033[36m"
|
||||||
|
#define TERM_COLOUR_FG_WHITE "\033[37m"
|
||||||
|
#define TERM_COLOUR_FG_BR_BLACK "\033[90m"
|
||||||
|
#define TERM_COLOUR_FG_BR_RED "\033[91m"
|
||||||
|
#define TERM_COLOUR_FG_BR_GREEN "\033[92m"
|
||||||
|
#define TERM_COLOUR_FG_BR_YELLOW "\033[93m"
|
||||||
|
#define TERM_COLOUR_FG_BR_BLUE "\033[94m"
|
||||||
|
#define TERM_COLOUR_FG_BR_MAGENTA "\033[95m"
|
||||||
|
#define TERM_COLOUR_FG_BR_CYAN "\033[96m"
|
||||||
|
#define TERM_COLOUR_FG_BR_WHITE "\033[97m"
|
||||||
|
#endif
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
TerminalColourist wapp_termcolour_get_colourist(void);
|
|
||||||
void wapp_termcolour_print_text(TerminalColourist *colourist, const char *text,
|
|
||||||
TerminalColour colour);
|
|
||||||
void wapp_termcolour_clear_colour(TerminalColourist *colourist);
|
|
||||||
|
|
||||||
#endif // !TERM_COLOUR_H
|
#endif // !TERM_COLOUR_H
|
||||||
|
@ -1,20 +1,16 @@
|
|||||||
#include "tester.h"
|
#include "tester.h"
|
||||||
#include "aliases.h"
|
#include "aliases.h"
|
||||||
#include "platform.h"
|
|
||||||
#include "termcolour.h"
|
#include "termcolour.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
internal void handle_test_result(TerminalColourist *colourist,
|
internal void print_test_result(TestFuncResult result);
|
||||||
TestFuncResult result);
|
|
||||||
|
|
||||||
void run_tests(TestFunc *func1, ...) {
|
void run_tests(TestFunc *func1, ...) {
|
||||||
TerminalColourist colourist = wapp_termcolour_get_colourist();
|
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
handle_test_result(&colourist, func1());
|
print_test_result(func1());
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, func1);
|
va_start(args, func1);
|
||||||
@ -23,7 +19,11 @@ void run_tests(TestFunc *func1, ...) {
|
|||||||
|
|
||||||
while (func) {
|
while (func) {
|
||||||
TestFuncResult result = func();
|
TestFuncResult result = func();
|
||||||
handle_test_result(&colourist, result);
|
print_test_result(result);
|
||||||
|
|
||||||
|
if (!result.passed) {
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
func = va_arg(args, TestFunc *);
|
func = va_arg(args, TestFunc *);
|
||||||
}
|
}
|
||||||
@ -33,25 +33,18 @@ void run_tests(TestFunc *func1, ...) {
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void handle_test_result(TerminalColourist *colourist,
|
internal void print_test_result(TestFuncResult result) {
|
||||||
TestFuncResult result) {
|
const char *colour;
|
||||||
TerminalColour colour;
|
|
||||||
const char *result_text;
|
const char *result_text;
|
||||||
|
|
||||||
if (result.passed) {
|
if (result.passed) {
|
||||||
colour = WAPP_TERM_COLOUR_FG_BR_GREEN;
|
colour = TERM_COLOUR_FG_BR_GREEN;
|
||||||
result_text = "PASSED";
|
result_text = "PASSED";
|
||||||
} else {
|
} else {
|
||||||
colour = WAPP_TERM_COLOUR_FG_BR_RED;
|
colour = TERM_COLOUR_FG_BR_RED;
|
||||||
result_text = "FAILED";
|
result_text = "FAILED";
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("[");
|
printf("[%s%s%s%s] %s\n", colour, TERM_COLOUR_BOLD, result_text,
|
||||||
wapp_termcolour_print_text(colourist, result_text, colour);
|
TERM_COLOUR_CLEAR, result.name);
|
||||||
wapp_termcolour_clear_colour(colourist);
|
|
||||||
printf("] %s\n", result.name);
|
|
||||||
|
|
||||||
if (!result.passed) {
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#define ARENA_CAPACITY 1024
|
#define ARENA_CAPACITY 1024
|
||||||
|
|
||||||
internal Arena *arena = NULL;
|
internal Arena *arena = NULL;
|
||||||
internal i32 count = 20;
|
internal u64 count = 20;
|
||||||
internal i32 *array = NULL;
|
internal i32 *array = NULL;
|
||||||
|
|
||||||
TestFuncResult test_arena_init(void) {
|
TestFuncResult test_arena_init(void) {
|
||||||
@ -20,8 +20,8 @@ TestFuncResult test_arena_init(void) {
|
|||||||
TestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) {
|
TestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) {
|
||||||
Arena *large_arena = NULL;
|
Arena *large_arena = NULL;
|
||||||
u64 capacity = 512ull * 1024ull * 1024ull * 1024ull;
|
u64 capacity = 512ull * 1024ull * 1024ull * 1024ull;
|
||||||
bool result = wapp_mem_arena_init(&large_arena, capacity,
|
bool result =
|
||||||
WAPP_MEM_ALLOC_RESERVE, false);
|
wapp_mem_arena_init(&large_arena, capacity, WAPP_MEM_ALLOC_RESERVE, false);
|
||||||
if (result) {
|
if (result) {
|
||||||
wapp_mem_arena_destroy(&large_arena);
|
wapp_mem_arena_destroy(&large_arena);
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ TestFuncResult test_arena_alloc_succeeds_when_within_capacity(void) {
|
|||||||
array = wapp_mem_arena_alloc(arena, count * sizeof(i32));
|
array = wapp_mem_arena_alloc(arena, count * sizeof(i32));
|
||||||
bool result = array != NULL;
|
bool result = array != NULL;
|
||||||
|
|
||||||
for (i32 i = 0; i < count; ++i) {
|
for (u64 i = 0; i < count; ++i) {
|
||||||
array[i] = i * 10;
|
array[i] = i * 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ TestFuncResult test_arena_clear(void) {
|
|||||||
wapp_mem_arena_clear(arena);
|
wapp_mem_arena_clear(arena);
|
||||||
bool result = true;
|
bool result = true;
|
||||||
|
|
||||||
for (i32 i = 0; i < count; ++i) {
|
for (u64 i = 0; i < count; ++i) {
|
||||||
if (array[i] != 0) {
|
if (array[i] != 0) {
|
||||||
result = false;
|
result = false;
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user