vgbc/tests/test_ram.cpp

33 lines
546 B
C++

#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();