Use doctest as test framework
This commit is contained in:
parent
b64c82ec92
commit
eb6faab89f
6 changed files with 7148 additions and 18 deletions
2
tests/doctest.cpp
Normal file
2
tests/doctest.cpp
Normal file
|
@ -0,0 +1,2 @@
|
|||
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||
#include "doctest.h"
|
7106
tests/doctest.h
Normal file
7106
tests/doctest.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,9 @@
|
|||
#include <iostream>
|
||||
#include "doctest.h"
|
||||
|
||||
#include "memory/bus.h"
|
||||
#include "memory/ram.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
TEST_CASE("Bus can map same device twice")
|
||||
{
|
||||
RAM r(0x1000);
|
||||
Bus b;
|
||||
|
@ -11,5 +12,5 @@ int main(int argc, char** argv)
|
|||
b.map_device(0x2000, 0x2FFF, &r);
|
||||
|
||||
b.write8(0x60, 42);
|
||||
return (b.read8(0x2060) == 42) ? 0 : 1;
|
||||
CHECK(b.read8(0x2060) == 42);
|
||||
}
|
||||
|
|
27
tests/test_cpu_simple.cpp
Normal file
27
tests/test_cpu_simple.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
#include "doctest.h"
|
||||
|
||||
#include "cpu/cpu.h"
|
||||
#include "memory/ram.h"
|
||||
|
||||
|
||||
TEST_CASE("simple load and add")
|
||||
{
|
||||
u8 test_ram[] = {
|
||||
0x3E, 0x10, // LD A, $0x10
|
||||
0x87, // ADD A, A
|
||||
};
|
||||
RAM r(test_ram, 3, true);
|
||||
Cpu cpu(&r);
|
||||
|
||||
CHECK(cpu.state.PC == 0x0);
|
||||
|
||||
cpu.step();
|
||||
|
||||
CHECK(cpu.state.PC == 0x2);
|
||||
CHECK(cpu.state.A == 0x10);
|
||||
|
||||
cpu.step();
|
||||
|
||||
CHECK(cpu.state.PC == 0x3);
|
||||
CHECK(cpu.state.A == 0x20);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue