Trying to use catch instead of critertion

This commit is contained in:
Zoe Roux
2021-07-03 17:38:57 +02:00
parent d558b00b0a
commit eb02c23eb9
33 changed files with 1813 additions and 1986 deletions
+14 -15
View File
@@ -2,14 +2,13 @@
// Created by anonymus-raccoon on 4/6/20.
//
#include <criterion/criterion.h>
#include <criterion/redirect.h>
#include <catch2/catch.hpp>
#include "tests.hpp"
#include "../sources/Memory/RectangleShadow.hpp"
using namespace ComSquare;
Test(RectangleMemory, HorizontalRamRead)
TEST_CASE("HorizontalRamRead RectangleMemory", "[RectangleMemory]")
{
Ram::Ram ram(0xFF, Component::Rom, "Rom");
ram.setMemoryRegion(0x00, 0xFF, 0x0000, 0x0000);
@@ -17,21 +16,21 @@ Test(RectangleMemory, HorizontalRamRead)
ram._data[i] = i;
for (uint24_t i = 0x000000; i < 0xFF0000; i += 0x010000) {
uint8_t value = ram.read(ram.getRelativeAddress(i));
cr_assert_eq(value, i >> 16u, "The ram's read returned 0x%x but the internal ram value was: 0x%x (addr: 0x%06x)", value, i >> 16, i);
REQUIRE(value == i >> 16u);
}
}
Test(RectangleMemory, HorizontalRamWrite)
TEST_CASE("HorizontalRamWrite RectangleMemory", "[RectangleMemory]")
{
Ram::Ram ram(0xFF, Component::Rom, "Rom");
ram.setMemoryRegion(0x00, 0xFF, 0x0000, 0x0000);
for (uint24_t i = 0x000000; i < 0xFF0000; i += 0x010000)
ram.write(ram.getRelativeAddress(i), i >> 16u);
for (int i = 0x00; i < 0xFF; i++)
cr_assert_eq(ram._data[i], i, "The ram's write put 0x%x but it should had put: 0x%x (addr: 0x%06x)", ram._data[i], i, i << 16u);
REQUIRE(ram._data[i] == i);
}
Test(RectangleMemory, DualLineRamRead)
TEST_CASE("DualLineRamRead RectangleMemory", "[RectangleMemory]")
{
Ram::Ram ram(0xFF * 2, Component::Rom, "Rom");
ram.setMemoryRegion(0x00, 0xFF, 0x0000, 0x0001);
@@ -39,13 +38,13 @@ Test(RectangleMemory, DualLineRamRead)
ram._data[i] = i;
for (uint24_t i = 0x000000, v = 0; v < 0xFF * 2; i += 0x010000, v += 2) {
uint8_t value = ram.read(ram.getRelativeAddress(i));
cr_assert_eq(value, (uint8_t)(v), "The ram's read returned 0x%x but the internal ram value was: 0x%x (addr: 0x%06x)", value, (uint8_t)(v), i);
REQUIRE(value == (uint8_t)(v));
value = ram.read(ram.getRelativeAddress(i + 1));
cr_assert_eq(value, (uint8_t)(v + 1), "The ram's read returned 0x%x but the internal ram value was: 0x%x (addr: 0x%06x)", value, (uint8_t)(v + 1), i + 1);
REQUIRE(value == (uint8_t)(v + 1));
}
}
Test(RectangleMemory, HorizontalRamShadowRead)
TEST_CASE("HorizontalRamShadowRead RectangleMemory", "[RectangleMemory]")
{
std::shared_ptr<Ram::Ram> ram = std::make_shared<Ram::Ram>(0xFF, Component::Rom, "Rom");
ram->setMemoryRegion(0x00, 0xFF, 0x0000, 0x0000);
@@ -54,10 +53,10 @@ Test(RectangleMemory, HorizontalRamShadowRead)
ram->_data[i] = i;
for (uint24_t i = 0x008000; i < 0xFF8000; i += 0x010000) {
uint8_t v = shadow.read(shadow.getRelativeAddress(i));
cr_assert_eq(v, i >> 16u, "The ram's read returned 0x%x but the internal ram value was: 0x%x (addr: 0x%06x)", v, i >> 16, i);
REQUIRE(v == i >> 16u);
}}
Test(RectangleMemory, HorizontalRamShadowReadWithBankOffset)
TEST_CASE("HorizontalRamShadowReadWithBankOffset RectangleMemory", "[RectangleMemory]")
{
std::shared_ptr<Ram::Ram> ram = std::make_shared<Ram::Ram>(0xFF, Component::Rom, "Rom");
ram->setMemoryRegion(0x00, 0xFF, 0x0000, 0x0000);
@@ -67,11 +66,11 @@ Test(RectangleMemory, HorizontalRamShadowReadWithBankOffset)
shadow.setBankOffset(0x80);
for (uint24_t i = 0x808000; i < 0xFF8000; i += 0x010000) {
uint8_t v = shadow.read(shadow.getRelativeAddress(i));
cr_assert_eq(v, i >> 16u, "The ram's read returned 0x%x but the internal ram value was: 0x%x (addr: 0x%06x)", v, i >> 16, i);
REQUIRE(v == i >> 16u);
}
}
Test(RectangleMemory, ShadowOffsetCartridge)
TEST_CASE("ShadowOffsetCartridge RectangleMemory", "[RectangleMemory]")
{
std::shared_ptr<Ram::Ram> ram = std::make_shared<Ram::Ram>(0x3fff80, Component::Rom, "Rom");
ram->setMemoryRegion(0x80, 0xFF, 0x8000, 0xFFFF);
@@ -84,6 +83,6 @@ Test(RectangleMemory, ShadowOffsetCartridge)
i += 0x010000 - 0x8000;
uint8_t v = shadow.read(shadow.getRelativeAddress(i));
uint8_t r = ram->read(ram->getRelativeAddress(i + 0x8000));
cr_assert_eq(v, r, "The ram's read returned 0x%x but the internal ram value was: 0x%x (addr: 0x%06x)", v, r, i);
REQUIRE(v == r);
}
}