2021-10-10 20:26:30 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-10-11 09:20:18 +00:00
|
|
|
#include <cstdint>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2021-10-10 20:26:30 +00:00
|
|
|
#include <Bus.h>
|
|
|
|
#include <Ram.h>
|
|
|
|
#include <mos6502.h>
|
|
|
|
|
|
|
|
#include "test_t.h"
|
|
|
|
|
|
|
|
class TestRunner final : public EightBit::Bus {
|
|
|
|
private:
|
|
|
|
EightBit::Ram m_ram = 0x10000;
|
|
|
|
EightBit::MOS6502 m_cpu = { *this };
|
|
|
|
const test_t& m_test;
|
2021-10-11 09:20:18 +00:00
|
|
|
std::vector<std::string> m_messages;
|
2021-10-10 20:26:30 +00:00
|
|
|
|
|
|
|
test_t::events_t m_actualEvents;
|
2021-10-11 09:20:18 +00:00
|
|
|
bool m_event_count_mismatch = false;
|
2021-10-10 20:26:30 +00:00
|
|
|
|
|
|
|
void initialiseState();
|
2021-10-11 09:20:18 +00:00
|
|
|
bool checkState();
|
2021-10-10 20:26:30 +00:00
|
|
|
|
|
|
|
void raise(std::string what, uint16_t expected, uint16_t actual);
|
|
|
|
void raise(std::string what, uint8_t expected, uint8_t actual);
|
|
|
|
void raise(std::string what, test_t::action expected, test_t::action actual);
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
bool check(std::string what, T expected, T actual) {
|
|
|
|
const auto success = actual == expected;
|
|
|
|
if (!success)
|
|
|
|
raise(what, expected, actual);
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
void addActualEvent(test_t::action action, uint16_t address, uint8_t value);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual EightBit::MemoryMapping mapping(uint16_t address) noexcept final;
|
|
|
|
|
|
|
|
public:
|
|
|
|
TestRunner(const test_t& test);
|
|
|
|
|
|
|
|
virtual void raisePOWER() final;
|
|
|
|
virtual void lowerPOWER() final;
|
|
|
|
|
|
|
|
virtual void initialise() final;
|
|
|
|
|
|
|
|
constexpr auto& RAM() noexcept { return m_ram; }
|
|
|
|
constexpr auto& CPU() noexcept { return m_cpu; }
|
|
|
|
constexpr const auto& test() const noexcept { return m_test; }
|
2021-10-11 09:20:18 +00:00
|
|
|
constexpr const auto& messages() const noexcept { return m_messages; }
|
2021-10-10 20:26:30 +00:00
|
|
|
|
2021-10-11 09:20:18 +00:00
|
|
|
bool check();
|
2021-10-10 20:26:30 +00:00
|
|
|
};
|