From 80c7f383684453726033db5a3141468f61501b88 Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Wed, 3 Jan 2018 01:00:51 -0600 Subject: [PATCH] Add test suite for apple2.mem.c --- tests/apple2.mem.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/apple2.mem.c diff --git a/tests/apple2.mem.c b/tests/apple2.mem.c new file mode 100644 index 0000000..2e3d3f9 --- /dev/null +++ b/tests/apple2.mem.c @@ -0,0 +1,33 @@ +#include + +#include "apple2.h" +#include "apple2.mem.h" + +static apple2 *mach = NULL; + +static void +setup() +{ + mach = apple2_create(100, 100); + apple2_mem_map(mach); +} + +static void +teardown() +{ + apple2_free(mach); +} + +TestSuite(apple2_mem, .init = setup, .fini = teardown); + +Test(apple2_mem, map) +{ + // mach already had the mem_map function run, so we just need to + // test the results. + size_t addr; + + for (addr = APPLE2_BANK_OFFSET; addr < MOS6502_MEMSIZE; addr++) { + cr_assert_eq(mach->memory->read_table[addr], apple2_mem_read_bank); + cr_assert_eq(mach->memory->write_table[addr], apple2_mem_write_bank); + } +}