mirror of
https://github.com/pevans/erc-c.git
synced 2024-11-17 00:04:43 +00:00
Add tests for apple2.kb.c
This commit is contained in:
parent
6670df930b
commit
53f40ff960
23
include/apple2.tests.h
Normal file
23
include/apple2.tests.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef _APPLE2_TESTS_H_
|
||||||
|
#define _APPLE2_TESTS_H_
|
||||||
|
|
||||||
|
#include "apple2.h"
|
||||||
|
#include "vm_segment.h"
|
||||||
|
|
||||||
|
static apple2 *mach = NULL;
|
||||||
|
|
||||||
|
static void
|
||||||
|
setup()
|
||||||
|
{
|
||||||
|
mach = apple2_create(100, 100);
|
||||||
|
vm_segment_set_map_machine(mach);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
teardown()
|
||||||
|
{
|
||||||
|
apple2_free(mach);
|
||||||
|
vm_segment_set_map_machine(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,38 @@
|
|||||||
|
#include <criterion/criterion.h>
|
||||||
|
|
||||||
|
#include "apple2.kb.h"
|
||||||
|
#include "apple2.tests.h"
|
||||||
|
|
||||||
|
TestSuite(apple2_kb, .init = setup, .fini = teardown);
|
||||||
|
|
||||||
|
Test(apple2_kb, map)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
vm_segment *segments[2];
|
||||||
|
|
||||||
|
segments[0] = mach->main;
|
||||||
|
segments[1] = mach->aux;
|
||||||
|
|
||||||
|
for (i = 0; i < 2; i++) {
|
||||||
|
cr_assert_eq(segments[i]->read_table[0xC000], apple2_kb_switch_read);
|
||||||
|
cr_assert_eq(segments[i]->read_table[0xC010], apple2_kb_switch_read);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Test(apple2_kb, switch_read)
|
||||||
|
{
|
||||||
|
// Without strobe
|
||||||
|
mach->screen->last_key = 'a';
|
||||||
|
cr_assert_eq(vm_segment_get(mach->main, 0xC000), 'a');
|
||||||
|
|
||||||
|
// With strobe
|
||||||
|
mach->strobe = true;
|
||||||
|
cr_assert_eq(vm_segment_get(mach->main, 0xC000), 'a' | 0x80);
|
||||||
|
|
||||||
|
mach->screen->key_pressed = true;
|
||||||
|
cr_assert_eq(vm_segment_get(mach->main, 0xC010), 0x80);
|
||||||
|
cr_assert_eq(mach->strobe, false);
|
||||||
|
|
||||||
|
mach->screen->key_pressed = false;
|
||||||
|
cr_assert_eq(vm_segment_get(mach->main, 0xC010), 0x00);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user