1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-11-04 22:09:08 +00:00
erc-c/tests/mos6502.branch.c

104 lines
2.0 KiB
C
Raw Normal View History

2017-12-04 02:19:17 +00:00
#include <criterion/criterion.h>
#include "mos6502.h"
#include "mos6502.enums.h"
#include "mos6502.tests.h"
2017-12-04 02:19:17 +00:00
TestSuite(mos6502_branch, .init = setup, .fini = teardown);
2017-12-04 02:19:17 +00:00
Test(mos6502_branch, bcc)
{
2017-12-04 02:19:17 +00:00
cpu->last_addr = 123;
mos6502_handle_bcc(cpu, 0);
cr_assert_eq(cpu->PC, 123);
cpu->P |= CARRY;
cpu->last_addr = 125;
mos6502_handle_bcc(cpu, 0);
cr_assert_neq(cpu->PC, 125);
}
Test(mos6502_branch, bcs)
2017-12-04 02:19:17 +00:00
{
cpu->last_addr = 123;
mos6502_handle_bcs(cpu, 0);
cr_assert_neq(cpu->PC, 123);
cpu->P |= CARRY;
cpu->last_addr = 125;
mos6502_handle_bcs(cpu, 0);
cr_assert_eq(cpu->PC, 125);
}
Test(mos6502_branch, beq)
2017-12-04 02:19:17 +00:00
{
cpu->last_addr = 123;
mos6502_handle_beq(cpu, 0);
cr_assert_neq(cpu->PC, 123);
cpu->P |= ZERO;
cpu->last_addr = 125;
mos6502_handle_beq(cpu, 0);
cr_assert_eq(cpu->PC, 125);
}
Test(mos6502_branch, bmi)
2017-12-04 02:19:17 +00:00
{
cpu->last_addr = 123;
mos6502_handle_bmi(cpu, 0);
cr_assert_neq(cpu->PC, 123);
cpu->P |= NEGATIVE;
cpu->last_addr = 125;
mos6502_handle_bmi(cpu, 0);
cr_assert_eq(cpu->PC, 125);
}
Test(mos6502_branch, bne)
2017-12-04 02:19:17 +00:00
{
cpu->last_addr = 123;
mos6502_handle_bne(cpu, 0);
cr_assert_eq(cpu->PC, 123);
cpu->P |= ZERO;
cpu->last_addr = 125;
mos6502_handle_bne(cpu, 0);
cr_assert_neq(cpu->PC, 125);
}
Test(mos6502_branch, bpl)
2017-12-04 02:19:17 +00:00
{
cpu->last_addr = 123;
mos6502_handle_bpl(cpu, 0);
cr_assert_eq(cpu->PC, 123);
cpu->P |= NEGATIVE;
cpu->last_addr = 125;
mos6502_handle_bpl(cpu, 0);
cr_assert_neq(cpu->PC, 125);
}
Test(mos6502_branch, bvc)
2017-12-04 02:19:17 +00:00
{
cpu->last_addr = 123;
mos6502_handle_bvc(cpu, 0);
cr_assert_eq(cpu->PC, 123);
cpu->P |= OVERFLOW;
cpu->last_addr = 125;
mos6502_handle_bvc(cpu, 0);
cr_assert_neq(cpu->PC, 125);
}
Test(mos6502_branch, bvs)
2017-12-04 02:19:17 +00:00
{
cpu->last_addr = 123;
mos6502_handle_bvs(cpu, 0);
cr_assert_neq(cpu->PC, 123);
cpu->P |= OVERFLOW;
cpu->last_addr = 125;
mos6502_handle_bvs(cpu, 0);
cr_assert_eq(cpu->PC, 125);
}