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