added cart unit tests
This commit is contained in:
parent
705be02543
commit
945b82a3ca
@ -20,3 +20,5 @@ typedef struct {
|
||||
} rom_header;
|
||||
|
||||
bool cart_load(char *cart);
|
||||
|
||||
rom_header *get_rom_header();
|
@ -5,9 +5,9 @@ typedef struct {
|
||||
u32 rom_size;
|
||||
u8 *rom_data;
|
||||
rom_header *header;
|
||||
} cert_context;
|
||||
} cart_context;
|
||||
|
||||
static cert_context ctx;
|
||||
static cart_context ctx;
|
||||
|
||||
static const char *ROM_TYPES[] = {
|
||||
"ROM ONLY",
|
||||
@ -111,6 +111,10 @@ static const char *LIC_CODE[0xA5] = {
|
||||
[0xA4] = "Konami (Yu-Gi-Oh!)"
|
||||
};
|
||||
|
||||
rom_header *get_rom_header() {
|
||||
return ctx.header;
|
||||
}
|
||||
|
||||
const char *cart_type_name() {
|
||||
if(ctx.header->type <= 0x22) {
|
||||
return ROM_TYPES[ctx.header->type];
|
||||
|
15
tests/test.c
15
tests/test.c
@ -5,17 +5,32 @@
|
||||
#include <emu.h>
|
||||
|
||||
#include <cpu.h>
|
||||
#include <cart.h>
|
||||
|
||||
START_TEST(test_nothing) {
|
||||
bool b = cpu_step();
|
||||
ck_assert_uint_eq(b, false);
|
||||
} END_TEST
|
||||
|
||||
START_TEST(test_cart) {
|
||||
bool b = cart_load("../../roms/cpu_instrs.gb");
|
||||
ck_assert_uint_eq(b, true);
|
||||
rom_header *header = get_rom_header();
|
||||
ck_assert_str_eq(header->title, "CPU_INSTRS");
|
||||
ck_assert_uint_eq(header->type, 0x01);
|
||||
ck_assert_uint_eq(header->rom_size, 0x01);
|
||||
ck_assert_uint_eq(header->ram_size, 0x00);
|
||||
ck_assert_uint_eq(header->lic_code, 0x00);
|
||||
ck_assert_uint_eq(header->version, 0x00);
|
||||
ck_assert_uint_eq(header->checksum, 0x3B);
|
||||
} END_TEST
|
||||
|
||||
Suite *stack_suite() {
|
||||
Suite *s = suite_create("emu");
|
||||
TCase *tc = tcase_create("core");
|
||||
|
||||
tcase_add_test(tc, test_nothing);
|
||||
tcase_add_test(tc, test_cart);
|
||||
suite_add_tcase(s, tc);
|
||||
|
||||
return s;
|
||||
|
Loading…
Reference in New Issue
Block a user