1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-07-20 07:28:56 +00:00

Add missing tests for reset, set_memory

This also consciously ignores tests for free() (handled implicitly in
all teardowns) and run_loop (for which I don't have a good notion to
test right now).
This commit is contained in:
Peter Evans 2018-01-07 13:43:09 -06:00
parent 6011580a99
commit 419b82faf1

View File

@ -1,6 +1,7 @@
#include <criterion/criterion.h> #include <criterion/criterion.h>
#include "apple2.h" #include "apple2.h"
#include "mos6502.enums.h"
#include "option.h" #include "option.h"
static apple2 *mach; static apple2 *mach;
@ -19,6 +20,9 @@ teardown()
TestSuite(apple2, .init = setup, .fini = teardown); TestSuite(apple2, .init = setup, .fini = teardown);
/* Test(apple2, free) */
/* Test(apple2, run_loop) */
Test(apple2, create) Test(apple2, create)
{ {
cr_assert_neq(mach, NULL); cr_assert_neq(mach, NULL);
@ -112,3 +116,23 @@ Test(apple2, set_video)
apple2_set_video(mach, VIDEO_LORES); apple2_set_video(mach, VIDEO_LORES);
cr_assert_eq(mach->video_mode, VIDEO_LORES); cr_assert_eq(mach->video_mode, VIDEO_LORES);
} }
Test(apple2, set_memory)
{
apple2_set_memory(mach, MEMORY_BANK_RAM1);
cr_assert_eq(mach->memory_mode, MEMORY_BANK_RAM1);
apple2_set_memory(mach, MEMORY_BANK_RAM2);
cr_assert_eq(mach->memory_mode, MEMORY_BANK_RAM2);
}
Test(apple2, reset)
{
apple2_set_memory(mach, MEMORY_BANK_ROM);
vm_segment_set(mach->rom, 0x2FFC, 0x12);
vm_segment_set(mach->rom, 0x2FFD, 0x34);
apple2_reset(mach);
cr_assert_eq(mach->cpu->PC, 0x1234);
cr_assert_eq(mach->cpu->P, MOS_INTERRUPT);
cr_assert_eq(mach->cpu->S, 0);
}