tests - Implement simple ram tests

This commit is contained in:
madmaurice 2023-08-28 23:08:19 +02:00
parent 6f8f90afbe
commit 0ce79045e3

32
tests/test_ram.cpp Normal file
View file

@ -0,0 +1,32 @@
#include "doctest.h"
#include "memory/ram.h"
TEST_SUITE_BEGIN("memory/ram");
TEST_CASE("byte order for 16-byte write is correct")
{
RAM r(0x10);
r.write16(0x0,0xAA55);
CHECK(r.read8(0x0) == 0x55);
CHECK(r.read8(0x1) == 0xAA);
}
TEST_CASE("byte order for 16-byte write is correct")
{
RAM r(0x10);
r.write8(0x0, 0x55);
r.write8(0x1, 0xAA);
CHECK(r.read16(0x0) == 0xAA55);
}
TEST_CASE("can be read only")
{
u8 data[1] = { 0x00 };
RAM r(data, 1, true);
r.write8(0,0x10);
CHECK(r.read8(0) == 0x00);
}
TEST_SUITE_END();