gbemu: refactor testing infrastructure

Similar to gbasm, break the testing into different files for sanity's
sake. This patch also adds a "test" register state which is compared
to the state of the actual CPU registers at the end of the test.

Finally, break the inc and dec tests, but add "ld r8, r8" and "ld dr,
d8" tests.
This commit is contained in:
2017-05-31 21:42:08 -07:00
parent 30df5164d6
commit 8dbcf353ab
5 changed files with 291 additions and 73 deletions

View File

@@ -23,15 +23,31 @@ struct gbasm_test r8_r8 = {
/*
* Data for LD R8, D8 tests
*/
static char ld_r8_d8_src[1024] = { 0 };
static uint8_t ld_r8_d8_output[0x40];
static char ld_r8_d8_src[] = "ld a, $12\n"
"ld b, $0\n"
"ld c, $0xff\n"
"ld d, $127\n"
"ld e, $0xfe\n"
"ld h, $-1\n"
"ld l, $-128\n"
"halt";
static uint8_t ld_r8_d8_output[] = {
0x3e, 0x0c,
0x06, 0x00,
0x0e, 0xff,
0x16, 0x7f,
0x1e, 0xfe,
0x26, 0xff,
0x2e, 0x80,
0x76,
};
struct gbasm_test r8_d8 = {
.init = init_r8_d8,
.name = "r8/d8",
.asm_source = ld_r8_d8_src,
.expected_output = ld_r8_d8_output,
.expected_output_len = 0,
.expected_output_len = 15,
};
static const struct gbasm_test *tests[] = {
@@ -105,26 +121,3 @@ void init_r8_r8(void)
gen_r8_r8_src();
gen_r8_r8_output();
}
void gen_r8_d8_src(void)
{
snprintf(ld_r8_d8_src,
sizeof(ld_r8_d8_src),
"ld a, $12\n"
"ld b, $0\n"
"ld c, $0xff\n"
"ld d, $127\n"
"ld e, $0xfe\n"
"ld h, $-1\n"
"ld l, $-128");
}
void gen_r8_d8_output(void)
{
}
void init_r8_d8(void)
{
gen_r8_d8_src();
gen_r8_d8_output();
}