From b0577cebc601eb9883a761dc328cfc6e6575faf5 Mon Sep 17 00:00:00 2001 From: Max Regan Date: Sat, 20 May 2017 16:50:49 -0700 Subject: [PATCH] gbasm: add support for generating source input By adding an "init" function per test, it is easier to generate code that would be laborious to write by hand. --- src/gbasm/tests/test.c | 4 ++++ src/gbasm/tests/test.h | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gbasm/tests/test.c b/src/gbasm/tests/test.c index a55cd4a..70adbac 100644 --- a/src/gbasm/tests/test.c +++ b/src/gbasm/tests/test.c @@ -36,6 +36,10 @@ static void run_test(const void *test_data) int rc; size_t len; + if (test->init != NULL) { + test->init(); + } + src = strdup(test->asm_source); memset(program, 0, sizeof(program)); diff --git a/src/gbasm/tests/test.h b/src/gbasm/tests/test.h index 6c17da4..20a806a 100644 --- a/src/gbasm/tests/test.h +++ b/src/gbasm/tests/test.h @@ -4,10 +4,11 @@ #include struct gbasm_test { + void (*init)(void); const char *name; const char *asm_source; const uint8_t *expected_output; - const int expected_output_len; + int expected_output_len; }; struct gbasm_tests {