mirror of
https://github.com/zoriya/ComSquare.git
synced 2025-12-06 07:16:17 +00:00
Updating to catch 3
This commit is contained in:
@@ -27,8 +27,8 @@ set(SOURCES
|
||||
sources/APU/APU.cpp
|
||||
sources/Exceptions/InvalidAddress.hpp
|
||||
sources/Exceptions/InvalidRom.hpp
|
||||
sources/Models/Int24.hpp
|
||||
sources/Models/Int24.hpp
|
||||
sources/Models/Ints.hpp
|
||||
sources/Models/Ints.hpp
|
||||
sources/Ram/Ram.cpp
|
||||
sources/Ram/Ram.hpp
|
||||
sources/Memory/MemoryShadow.cpp
|
||||
@@ -186,16 +186,11 @@ add_executable(unit_tests EXCLUDE_FROM_ALL
|
||||
)
|
||||
target_include_directories(unit_tests PUBLIC tests)
|
||||
target_compile_definitions(unit_tests PUBLIC TESTS)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/libs)
|
||||
find_package(Catch2 REQUIRED)
|
||||
target_link_libraries(unit_tests PRIVATE Catch2::Catch2WithMain)
|
||||
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
# target_link_libraries(unit_tests PRIVATE -lgcov)
|
||||
# target_compile_options(unit_tests PUBLIC -fprofile-arcs -ftest-coverage)
|
||||
endif ()
|
||||
|
||||
find_package(Catch2 QUIET)
|
||||
if (NOT Catch2_FOUND)
|
||||
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/libs)
|
||||
find_package(Catch2 REQUIRED)
|
||||
endif ()
|
||||
target_link_libraries(unit_tests PRIVATE Catch2::Catch2)
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.11)
|
||||
cmake_minimum_required(VERSION 3.11)
|
||||
|
||||
|
||||
if (NOT Catch2_FOUND)
|
||||
Include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
Catch2
|
||||
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
||||
GIT_TAG v2.13.6)
|
||||
|
||||
FetchContent_MakeAvailable(Catch2)
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(Catch2
|
||||
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
||||
GIT_TAG v3.0.0-preview3
|
||||
)
|
||||
FetchContent_GetProperties(Catch2)
|
||||
if(NOT Catch2_POPULATED)
|
||||
FetchContent_Populate(Catch2)
|
||||
add_subdirectory(${catch2_SOURCE_DIR} ${catch2_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Created by Melefo on 24/02/2020.
|
||||
//
|
||||
|
||||
#include "../Models/Int24.hpp"
|
||||
#include "../Models/Ints.hpp"
|
||||
#include "APU.hpp"
|
||||
|
||||
namespace ComSquare::APU
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Created by anonymus-raccoon on 3/20/20.
|
||||
//
|
||||
|
||||
#include "../Models/Int24.hpp"
|
||||
#include "../Models/Ints.hpp"
|
||||
#include "CPU.hpp"
|
||||
|
||||
namespace ComSquare::CPU
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "Memory/AMemory.hpp"
|
||||
#include "Memory/MemoryBus.hpp"
|
||||
#include "Models/Int24.hpp"
|
||||
#include "Models/Ints.hpp"
|
||||
#include "Models/Callback.hpp"
|
||||
#include "Cartridge/Cartridge.hpp"
|
||||
#include "Memory/AMemory.hpp"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Memory/MemoryBus.hpp"
|
||||
#include "Models/Int24.hpp"
|
||||
#include "Models/Ints.hpp"
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "Models/Int24.hpp"
|
||||
#include "Models/Ints.hpp"
|
||||
|
||||
namespace ComSquare::CPU
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include "../../Models/Int24.hpp"
|
||||
#include "../../Models/Ints.hpp"
|
||||
#include "../CPU.hpp"
|
||||
|
||||
namespace ComSquare::CPU
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Models/Int24.hpp"
|
||||
#include "Models/Ints.hpp"
|
||||
|
||||
namespace ComSquare::CPU
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "InterruptVectors.hpp"
|
||||
#include "Memory/AMemory.hpp"
|
||||
#include "Memory/ARectangleMemory.hpp"
|
||||
#include "Models/Int24.hpp"
|
||||
#include "Models/Ints.hpp"
|
||||
#include "Ram/Ram.hpp"
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "Debugger/ClosableWindow.hpp"
|
||||
#include "Exceptions/DebuggableError.hpp"
|
||||
#include "ui/ui_cpuView.h"
|
||||
#include "Models/Int24.hpp"
|
||||
#include "Models/Ints.hpp"
|
||||
#include "Memory/MemoryBus.hpp"
|
||||
#include "CPU/Instruction.hpp"
|
||||
#include <QtWidgets/QStyledItemDelegate>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "ClosableWindow.hpp"
|
||||
#include "Memory/MemoryBus.hpp"
|
||||
#include "Models/Int24.hpp"
|
||||
#include "Models/Ints.hpp"
|
||||
#include "ui/ui_registersView.h"
|
||||
#include <QAbstractTableModel>
|
||||
#include <QtCore/QObject>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "DebuggableError.hpp"
|
||||
#include "Models/Ints.hpp"
|
||||
#include <exception>
|
||||
#include <ios>
|
||||
#include <sstream>
|
||||
@@ -22,7 +23,7 @@ namespace ComSquare
|
||||
InvalidAddress(std::string where, uint24_t addr)
|
||||
{
|
||||
std::stringstream stream;
|
||||
stream << "Could not read/write data at address: 0x" << std::hex << addr << " from " << where;
|
||||
stream << "Could not read/write data at address: " << addr << " from " << where;
|
||||
this->_msg = stream.str();
|
||||
}
|
||||
const char *what() const noexcept override { return this->_msg.c_str(); }
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "Models/Int24.hpp"
|
||||
#include "Models/Ints.hpp"
|
||||
#include "Models/Components.hpp"
|
||||
#include "IMemory.hpp"
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "IMemory.hpp"
|
||||
#include "Models/Ints.hpp"
|
||||
|
||||
namespace ComSquare::Memory
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "Models/Int24.hpp"
|
||||
#include "Models/Ints.hpp"
|
||||
#include "Models/Components.hpp"
|
||||
|
||||
namespace ComSquare::Memory
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace ComSquare::Memory
|
||||
IMemory *handler = this->getAccessor(addr);
|
||||
|
||||
if (!handler) {
|
||||
log(LogLevel::WARNING, "Unknown memory accessor for address $" << std::hex << addr << ". Using open bus.");
|
||||
logMsg(LogLevel::WARNING, "Unknown memory accessor for address $" << std::hex << addr << ". Using open bus.");
|
||||
return this->_openBus;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace ComSquare::Memory
|
||||
IMemory *handler = this->getAccessor(addr);
|
||||
|
||||
if (!handler) {
|
||||
log(LogLevel::ERROR, "Unknown memory accessor for address " << std::hex << addr << ". Warning, it was a write.");
|
||||
logMsg(LogLevel::ERROR, "Unknown memory accessor for address " << std::hex << addr << ". Warning, it was a write.");
|
||||
return;
|
||||
}
|
||||
handler->write(handler->getRelativeAddress(addr), data);
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
//
|
||||
// Created by anonymus-raccoon on 1/28/20.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned uint24_t;
|
||||
13
sources/Models/Ints.hpp
Normal file
13
sources/Models/Ints.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// Created by anonymus-raccoon on 1/28/20.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cinttypes>
|
||||
#include <iostream>
|
||||
|
||||
typedef unsigned uint24_t;
|
||||
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, uint8_t value);
|
||||
@@ -23,10 +23,10 @@ namespace ComSquare
|
||||
constexpr LogLevel GlobalLevel = INFO;
|
||||
|
||||
#ifndef TESTS
|
||||
#define log(level, message) \
|
||||
#define logMsg(level, message) \
|
||||
if constexpr((level) >= GlobalLevel) \
|
||||
std::cout << message << std::endl // NOLINT(bugprone-macro-parentheses)
|
||||
#else
|
||||
#define log(_, msg) INFO(msg)
|
||||
#define logMsg(_, msg) INFO(msg)
|
||||
#endif
|
||||
}
|
||||
@@ -58,7 +58,7 @@ namespace ComSquare::Renderer
|
||||
}
|
||||
#ifdef DEBUGGER_ENABLED
|
||||
catch (const DebuggableError &e) {
|
||||
log(LogLevel::ERROR, "Invalid rom's instruction: " << e.what());
|
||||
logMsg(LogLevel::ERROR, "Invalid rom's instruction: " << e.what());
|
||||
this->_snes.enableCPUDebuggingWithError(e);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -15,7 +15,9 @@ namespace ComSquare
|
||||
cpu(this->bus, cartridge.header),
|
||||
ppu(renderer),
|
||||
apu(renderer)
|
||||
{}
|
||||
{
|
||||
this->bus.mapComponents(*this);
|
||||
}
|
||||
|
||||
SNES::SNES(const std::string &romPath, Renderer::IRenderer &renderer)
|
||||
: bus(),
|
||||
|
||||
@@ -55,6 +55,9 @@ namespace ComSquare::Utility
|
||||
{
|
||||
return std::bitset<24>(i).to_string();
|
||||
}
|
||||
}
|
||||
|
||||
const std::string WHITESPACES = " \t\n\r\f\v";
|
||||
std::ostream &operator<<(std::ostream &os, uint8_t value)
|
||||
{
|
||||
return os << ComSquare::Utility::to_hex(value);
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <string>
|
||||
#include <ios>
|
||||
#include <sstream>
|
||||
#include "Models/Int24.hpp"
|
||||
#include "Models/Ints.hpp"
|
||||
|
||||
namespace ComSquare::Utility
|
||||
{
|
||||
@@ -25,5 +25,5 @@ namespace ComSquare::Utility
|
||||
std::string to_binary(uint16_t i);
|
||||
std::string to_binary(uint24_t i);
|
||||
|
||||
extern const std::string WHITESPACES;
|
||||
constexpr std::string_view WHITESPACES = " \t\n\r\f\v";
|
||||
}
|
||||
@@ -2,13 +2,13 @@
|
||||
// Created by cbihan on 2/11/20.
|
||||
//
|
||||
|
||||
#include <catch2/catch.hpp>
|
||||
#include <iostream>
|
||||
#include "Models/Ints.hpp"
|
||||
#include <bitset>
|
||||
#include "../tests.hpp"
|
||||
#include "../../sources/SNES.hpp"
|
||||
#include "../../sources/Memory/MemoryBus.hpp"
|
||||
#include "../../sources/PPU/PPU.hpp"
|
||||
#include "tests.hpp"
|
||||
#include <catch2/catch.hpp>
|
||||
#include "SNES.hpp"
|
||||
#include "Memory/MemoryBus.hpp"
|
||||
#include "PPU/PPU.hpp"
|
||||
using namespace ComSquare;
|
||||
|
||||
TEST_CASE("vmain_data_full PPU_write_2", "[PPU_write_2]")
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
#define private public
|
||||
#define protected public
|
||||
#define class struct
|
||||
|
||||
#include "Renderer/NoRenderer.hpp"
|
||||
#include "SNES.hpp"
|
||||
|
||||
Reference in New Issue
Block a user