diff --git a/tests/test_ram.cpp b/tests/test_ram.cpp new file mode 100644 index 0000000..73e1d33 --- /dev/null +++ b/tests/test_ram.cpp @@ -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();