mirror of
https://github.com/pevans/erc-c.git
synced 2024-11-01 04:04:28 +00:00
00ff9f069d
Criterion's init and fini config options allow us to register setup and teardown functions. We now use this to register the common cpu variable for the mos6502 tests, albeit through the use of a global variable. Doing so necessitated that each of the different test files have their own suites, due to some implementation details in Criterion, but this is No Big Deal.
57 lines
1.0 KiB
C
57 lines
1.0 KiB
C
#include <criterion/criterion.h>
|
|
|
|
#include "mos6502.h"
|
|
#include "mos6502.enums.h"
|
|
#include "mos6502.tests.h"
|
|
|
|
TestSuite(mos6502_stat, .init = setup, .fini = teardown);
|
|
|
|
Test(mos6502_stat, clc)
|
|
{
|
|
cpu->P = CARRY | DECIMAL;
|
|
mos6502_handle_clc(cpu, 0);
|
|
cr_assert_eq(cpu->P & CARRY, 0);
|
|
}
|
|
|
|
Test(mos6502_stat, cld)
|
|
{
|
|
cpu->P = DECIMAL | CARRY;
|
|
mos6502_handle_cld(cpu, 0);
|
|
cr_assert_eq(cpu->P & DECIMAL, 0);
|
|
}
|
|
|
|
Test(mos6502_stat, cli)
|
|
{
|
|
cpu->P = CARRY | INTERRUPT;
|
|
mos6502_handle_cli(cpu, 0);
|
|
cr_assert_eq(cpu->P & INTERRUPT, 0);
|
|
}
|
|
|
|
Test(mos6502_stat, clv)
|
|
{
|
|
cpu->P = CARRY | OVERFLOW;
|
|
mos6502_handle_clv(cpu, 0);
|
|
cr_assert_eq(cpu->P & OVERFLOW, 0);
|
|
}
|
|
|
|
Test(mos6502_stat, sec)
|
|
{
|
|
cpu->P = 0;
|
|
mos6502_handle_sec(cpu, 0);
|
|
cr_assert_eq(cpu->P & CARRY, CARRY);
|
|
}
|
|
|
|
Test(mos6502_stat, sed)
|
|
{
|
|
cpu->P = 0;
|
|
mos6502_handle_sed(cpu, 0);
|
|
cr_assert_eq(cpu->P & DECIMAL, DECIMAL);
|
|
}
|
|
|
|
Test(mos6502_stat, sei)
|
|
{
|
|
cpu->P = 0;
|
|
mos6502_handle_sei(cpu, 0);
|
|
cr_assert_eq(cpu->P & INTERRUPT, INTERRUPT);
|
|
}
|