1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-12-21 08:30:55 +00:00

Add tests for would_jump, flash_memory

This commit is contained in:
Peter Evans 2018-01-07 15:47:26 -06:00
parent 366f10efcb
commit 7b2450131e

View File

@ -6,6 +6,8 @@
TestSuite(mos6502, .init = setup, .fini = teardown);
/* Test(mos6502, free) */
Test(mos6502, create)
{
cr_assert_neq(cpu, NULL);
@ -117,3 +119,44 @@ Test(mos6502, read_byte)
vm_segment_set(cpu->memory, 0, 0x54);
cr_assert_eq(mos6502_read_byte(cpu), 0x54);
}
Test(mos6502, would_jump)
{
bool expect;
for (int inst = 0; inst <= TYA; inst++) {
switch (inst) {
case BCC:
case BCS:
case BEQ:
case BMI:
case BNE:
case BPL:
case BRK:
case BVC:
case BVS:
case JMP:
case JSR:
expect = true;
break;
default:
expect = false;
break;
}
cr_assert_eq(mos6502_would_jump(inst), expect);
}
}
Test(mos6502, flash_memory)
{
vm_segment *segment;
segment = vm_segment_create(MOS6502_MEMSIZE);
vm_segment_set(segment, 0, 123);
vm_segment_set(segment, 1, 124);
mos6502_flash_memory(cpu, segment);
cr_assert_eq(vm_segment_get(cpu->memory, 0), 123);
cr_assert_eq(vm_segment_get(cpu->memory, 1), 124);
}