From 419b82faf11a53547d79a658f139430fbea252b6 Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Sun, 7 Jan 2018 13:43:09 -0600 Subject: [PATCH] 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). --- tests/apple2.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/apple2.c b/tests/apple2.c index 585b953..29961b0 100644 --- a/tests/apple2.c +++ b/tests/apple2.c @@ -1,6 +1,7 @@ #include #include "apple2.h" +#include "mos6502.enums.h" #include "option.h" static apple2 *mach; @@ -19,6 +20,9 @@ teardown() TestSuite(apple2, .init = setup, .fini = teardown); +/* Test(apple2, free) */ +/* Test(apple2, run_loop) */ + Test(apple2, create) { cr_assert_neq(mach, NULL); @@ -112,3 +116,23 @@ Test(apple2, set_video) apple2_set_video(mach, 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); +}