Recreate base64 project

This commit is contained in:
2025-08-10 23:30:27 +01:00
commit e90d14344e
63 changed files with 11139 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
// vim:fileencoding=utf-8:foldmethod=marker
#include "tester.h"
#include "../../common/aliases/aliases.h"
#include "../../core/os/shell/termcolour/termcolour.h"
#include "../../primitives/strings/str8/str8.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
internal void handle_test_result(TestFuncResult result);
void run_tests(TestFunc *func1, ...) {
printf("\n");
handle_test_result(func1());
va_list args;
va_start(args, func1);
TestFunc *func = va_arg(args, TestFunc *);
while (func) {
TestFuncResult result = func();
handle_test_result(result);
func = va_arg(args, TestFunc *);
}
va_end(args);
printf("\n");
}
internal void handle_test_result(TestFuncResult result) {
TerminalColour colour;
Str8 result_text = wapp_str8_buf(64);
if (result.passed) {
colour = WAPP_TERM_COLOUR_FG_BR_GREEN;
wapp_str8_copy_cstr_capped(&result_text, "PASSED");
} else {
colour = WAPP_TERM_COLOUR_FG_BR_RED;
wapp_str8_copy_cstr_capped(&result_text, "FAILED");
}
printf("[");
wapp_shell_termcolour_print_text(&result_text, colour);
wapp_shell_termcolour_clear_colour();
printf("] " WAPP_STR8_SPEC "\n", wapp_str8_varg(result.name));
if (!result.passed) {
exit(EXIT_FAILURE);
}
}

View File

@@ -0,0 +1,41 @@
// vim:fileencoding=utf-8:foldmethod=marker
#ifndef TESTER_H
#define TESTER_H
#include "../../common/misc/misc_utils.h"
#include "../../common/platform/platform.h"
#include "../../primitives/strings/str8/str8.h"
#include <stdbool.h>
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
#ifdef WAPP_PLATFORM_CPP
#define wapp_tester_result(PASSED) (TestFuncResult{wapp_str8_lit_ro(__func__), PASSED})
#else
#define wapp_tester_result(PASSED) ((TestFuncResult){.name = wapp_str8_lit_ro(__func__), .passed = PASSED})
#endif // !WAPP_PLATFORM_CPP
#define wapp_tester_run_tests(...) run_tests(__VA_ARGS__, NULL)
typedef struct test_func_result TestFuncResult;
struct test_func_result {
Str8RO name;
bool passed;
#ifdef WAPP_PLATFORM_WINDOWS
wapp_misc_utils_padding_size(sizeof(Str8RO) + sizeof(bool));
#endif // WAPP_PLATFORM_WINDOWS
};
typedef TestFuncResult(TestFunc)(void);
void run_tests(TestFunc *func1, ...);
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
#endif // !TESTER_H

View File

@@ -0,0 +1,10 @@
// vim:fileencoding=utf-8:foldmethod=marker
#ifndef WAPP_TESTING_C
#define WAPP_TESTING_C
#include "wapp_testing.h"
#include "tester/tester.c"
#include "../core/wapp_core.c"
#endif // !WAPP_TESTING_C

View File

@@ -0,0 +1,10 @@
// vim:fileencoding=utf-8:foldmethod=marker
#ifndef WAPP_TESTING_H
#define WAPP_TESTING_H
#include "tester/tester.h"
#include "../common/wapp_common.h"
#include "../core/wapp_core.h"
#endif // !WAPP_TESTING_H