From 0ce79045e3961955a38c925f41adb4a565c0841c Mon Sep 17 00:00:00 2001 From: MadMaurice Date: Mon, 28 Aug 2023 23:08:19 +0200 Subject: [PATCH] tests - Implement simple ram tests --- tests/test_ram.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/test_ram.cpp 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();