2017-12-06 20:36:14 +00:00
|
|
|
#include <criterion/criterion.h>
|
|
|
|
|
|
|
|
#include "apple2.h"
|
|
|
|
|
2017-12-06 21:21:39 +00:00
|
|
|
static apple2 *mach;
|
2017-12-06 20:36:14 +00:00
|
|
|
|
2017-12-06 21:21:39 +00:00
|
|
|
void
|
|
|
|
setup()
|
|
|
|
{
|
2017-12-06 20:36:14 +00:00
|
|
|
mach = apple2_create();
|
2017-12-06 21:21:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
teardown()
|
|
|
|
{
|
|
|
|
apple2_free(mach);
|
|
|
|
}
|
|
|
|
|
|
|
|
TestSuite(apple2, .init = setup, .fini = teardown);
|
|
|
|
|
|
|
|
Test(apple2, create)
|
|
|
|
{
|
2017-12-06 20:36:14 +00:00
|
|
|
cr_assert_neq(mach, NULL);
|
|
|
|
cr_assert_neq(mach->cpu, NULL);
|
|
|
|
}
|
2017-12-06 21:21:39 +00:00
|
|
|
|
|
|
|
Test(apple2, press_key)
|
|
|
|
{
|
|
|
|
apple2_press_key(mach, 123);
|
|
|
|
cr_assert_eq(vm_segment_get(mach->memory, 0xC000), 123 | 0x80);
|
|
|
|
cr_assert_eq(vm_segment_get(mach->memory, 0xC010), 0x80);
|
|
|
|
}
|
|
|
|
|
|
|
|
Test(apple2, clear_strobe)
|
|
|
|
{
|
|
|
|
apple2_press_key(mach, 123);
|
|
|
|
cr_assert_eq(vm_segment_get(mach->memory, 0xC000), 123 | 0x80);
|
|
|
|
apple2_clear_strobe(mach);
|
|
|
|
cr_assert_eq(vm_segment_get(mach->memory, 0xC000), 123);
|
|
|
|
}
|
|
|
|
|
|
|
|
Test(apple2, release_key)
|
|
|
|
{
|
|
|
|
apple2_press_key(mach, 123);
|
|
|
|
cr_assert_eq(vm_segment_get(mach->memory, 0xC010), 0x80);
|
|
|
|
apple2_release_key(mach);
|
|
|
|
cr_assert_eq(vm_segment_get(mach->memory, 0xC010), 0);
|
|
|
|
}
|