Update test paths after flattening v0 layout
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
#include "test.h"
|
||||
#include "../src/buffer.h"
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static jmp_buf s_testJmp;
|
||||
static const char* s_failMsg;
|
||||
|
||||
void fail(const char* msg) {
|
||||
s_failMsg = msg;
|
||||
longjmp(s_testJmp, 1);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
const char* name;
|
||||
Test func;
|
||||
} TestCase;
|
||||
|
||||
#include "test_buffer.c"
|
||||
|
||||
static int s_totalTests;
|
||||
static int s_greenTests;
|
||||
|
||||
static TestCase s_tests[] = {
|
||||
{"buffer_string_reads_chars", test_buffer_string_reads_chars},
|
||||
{"buffer_string_eof", test_buffer_string_eof},
|
||||
{"buffer_string_eof_after_content", test_buffer_string_eof_after_content},
|
||||
{"buffer_file_reads_chars", test_buffer_file_reads_chars},
|
||||
{"buffer_file_open_fail", test_buffer_file_open_fail},
|
||||
};
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
s_totalTests = sizeof(s_tests) / sizeof(s_tests[0]);
|
||||
s_greenTests = 0;
|
||||
|
||||
const char* failedTests[s_totalTests + 1];
|
||||
int failedCount = 0;
|
||||
|
||||
for (int i = 0; i < s_totalTests; i++) {
|
||||
printf("%s...", s_tests[i].name);
|
||||
s_failMsg = NULL;
|
||||
|
||||
if (setjmp(s_testJmp) == 0) {
|
||||
s_tests[i].func();
|
||||
printf(" [OK]\n");
|
||||
s_greenTests++;
|
||||
} else {
|
||||
printf(" [FAIL]: %s\n", s_failMsg ? s_failMsg : "");
|
||||
failedTests[failedCount++] = s_tests[i].name;
|
||||
}
|
||||
}
|
||||
|
||||
if (failedCount > 0) {
|
||||
printf("\nFailed tests:\n");
|
||||
for (int i = 0; i < failedCount; i++) {
|
||||
printf(" - %s\n", failedTests[i]);
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n%d/%d tests passed.\n", s_greenTests, s_totalTests);
|
||||
return failedCount > 0 ? 1 : 0;
|
||||
}
|
||||
Reference in New Issue
Block a user