mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-02-08 03:30:36 +00:00
Add nodiscard attributes, where needed
Signed-off-by: Adrian Conlon <adrian.conlon@gmail.com>
This commit is contained in:
parent
4be61a9d54
commit
5686906583
@ -39,7 +39,6 @@ void TestRunner::initialise() {
|
|||||||
WrittenByte.connect([this](EightBit::EventArgs&) {
|
WrittenByte.connect([this](EightBit::EventArgs&) {
|
||||||
addActualEvent(test_t::action::write, ADDRESS().word, DATA());
|
addActualEvent(test_t::action::write, ADDRESS().word, DATA());
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestRunner::raise(std::string what, uint16_t expected, uint16_t actual) {
|
void TestRunner::raise(std::string what, uint16_t expected, uint16_t actual) {
|
||||||
|
@ -21,14 +21,14 @@ private:
|
|||||||
bool m_event_count_mismatch = false;
|
bool m_event_count_mismatch = false;
|
||||||
|
|
||||||
void initialiseState();
|
void initialiseState();
|
||||||
bool checkState();
|
[[nodiscard]] bool checkState();
|
||||||
|
|
||||||
void raise(std::string what, uint16_t expected, uint16_t actual);
|
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, uint8_t expected, uint8_t actual);
|
||||||
void raise(std::string what, test_t::action expected, test_t::action actual);
|
void raise(std::string what, test_t::action expected, test_t::action actual);
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
bool check(std::string what, T expected, T actual) {
|
[[nodiscard]] bool check(std::string what, T expected, T actual) {
|
||||||
const auto success = actual == expected;
|
const auto success = actual == expected;
|
||||||
if (!success)
|
if (!success)
|
||||||
raise(what, expected, actual);
|
raise(what, expected, actual);
|
||||||
@ -48,10 +48,10 @@ public:
|
|||||||
|
|
||||||
virtual void initialise() final;
|
virtual void initialise() final;
|
||||||
|
|
||||||
constexpr auto& RAM() noexcept { return m_ram; }
|
[[nodiscard]] constexpr auto& RAM() noexcept { return m_ram; }
|
||||||
constexpr auto& CPU() noexcept { return m_cpu; }
|
[[nodiscard]] constexpr auto& CPU() noexcept { return m_cpu; }
|
||||||
constexpr const auto& test() const noexcept { return m_test; }
|
[[nodiscard]] constexpr const auto& test() const noexcept { return m_test; }
|
||||||
constexpr const auto& messages() const noexcept { return m_messages; }
|
[[nodiscard]] constexpr const auto& messages() const noexcept { return m_messages; }
|
||||||
|
|
||||||
bool check();
|
[[nodiscard]] bool check();
|
||||||
};
|
};
|
||||||
|
@ -1,24 +1,25 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <boost/json.hpp>
|
#include <boost/json.hpp>
|
||||||
|
|
||||||
class json_t {
|
class json_t {
|
||||||
protected:
|
protected:
|
||||||
static const boost::json::value& get_value(const boost::json::object& object, std::string key);
|
[[nodiscard]] static const boost::json::value& get_value(const boost::json::object& object, std::string key);
|
||||||
|
|
||||||
static int64_t get_int64(const boost::json::value& value);
|
[[nodiscard]] static int64_t get_int64(const boost::json::value& value);
|
||||||
static uint16_t get_uint16(const boost::json::value& value);
|
[[nodiscard]] static uint16_t get_uint16(const boost::json::value& value);
|
||||||
static uint8_t get_uint8(const boost::json::value& value);
|
[[nodiscard]] static uint8_t get_uint8(const boost::json::value& value);
|
||||||
|
|
||||||
static int64_t get_int64(const boost::json::object& object, std::string key);
|
[[nodiscard]] static int64_t get_int64(const boost::json::object& object, std::string key);
|
||||||
static uint16_t get_uint16(const boost::json::object& object, std::string key);
|
[[nodiscard]] static uint16_t get_uint16(const boost::json::object& object, std::string key);
|
||||||
static uint8_t get_uint8(const boost::json::object& object, std::string key);
|
[[nodiscard]] static uint8_t get_uint8(const boost::json::object& object, std::string key);
|
||||||
|
|
||||||
static const boost::json::array& get_array(const boost::json::value& value);
|
[[nodiscard]] static const boost::json::array& get_array(const boost::json::value& value);
|
||||||
static const boost::json::array& get_array(const boost::json::object& object, std::string key);
|
[[nodiscard]] static const boost::json::array& get_array(const boost::json::object& object, std::string key);
|
||||||
|
|
||||||
static const boost::json::string& get_string(const boost::json::value& value);
|
[[nodiscard]] static const boost::json::string& get_string(const boost::json::value& value);
|
||||||
static const boost::json::string& get_string(const boost::json::object& object, std::string key);
|
[[nodiscard]] static const boost::json::string& get_string(const boost::json::object& object, std::string key);
|
||||||
};
|
};
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
class opcode_test_suite_t final {
|
class opcode_test_suite_t final {
|
||||||
private:
|
private:
|
||||||
static std::string read(std::string path);
|
[[nodiscard]] static std::string read(std::string path);
|
||||||
|
|
||||||
std::string m_path;
|
std::string m_path;
|
||||||
boost::json::value m_raw;
|
boost::json::value m_raw;
|
||||||
@ -13,9 +13,9 @@ private:
|
|||||||
public:
|
public:
|
||||||
opcode_test_suite_t(std::string path);
|
opcode_test_suite_t(std::string path);
|
||||||
|
|
||||||
constexpr const auto& path() const noexcept { return m_path; }
|
[[nodiscard]] constexpr const auto& path() const noexcept { return m_path; }
|
||||||
constexpr const auto& raw() const noexcept { return m_raw; }
|
[[nodiscard]] constexpr const auto& raw() const noexcept { return m_raw; }
|
||||||
const boost::json::array& get_array() const noexcept;
|
[[nodiscard]] const boost::json::array& get_array() const noexcept;
|
||||||
|
|
||||||
void load();
|
void load();
|
||||||
};
|
};
|
||||||
|
@ -18,7 +18,7 @@ private:
|
|||||||
uint8_t m_p = 0xff;
|
uint8_t m_p = 0xff;
|
||||||
std::unordered_map<uint16_t, uint8_t> m_ram;
|
std::unordered_map<uint16_t, uint8_t> m_ram;
|
||||||
|
|
||||||
constexpr auto initialised() const noexcept { return m_initialised; }
|
[[nodiscard]] constexpr auto initialised() const noexcept { return m_initialised; }
|
||||||
|
|
||||||
void initialise(const boost::json::object& serialised);
|
void initialise(const boost::json::object& serialised);
|
||||||
|
|
||||||
@ -27,11 +27,11 @@ public:
|
|||||||
state_t(const boost::json::object& serialised);
|
state_t(const boost::json::object& serialised);
|
||||||
state_t(const boost::json::value& serialised);
|
state_t(const boost::json::value& serialised);
|
||||||
|
|
||||||
constexpr auto pc() const noexcept { return m_pc; }
|
[[nodiscard]] constexpr auto pc() const noexcept { return m_pc; }
|
||||||
constexpr auto s() const noexcept { return m_s; }
|
[[nodiscard]] constexpr auto s() const noexcept { return m_s; }
|
||||||
constexpr auto a() const noexcept { return m_a; }
|
[[nodiscard]] constexpr auto a() const noexcept { return m_a; }
|
||||||
constexpr auto x() const noexcept { return m_x; }
|
[[nodiscard]] constexpr auto x() const noexcept { return m_x; }
|
||||||
constexpr auto y() const noexcept { return m_y; }
|
[[nodiscard]] constexpr auto y() const noexcept { return m_y; }
|
||||||
constexpr auto p() const noexcept { return m_p; }
|
[[nodiscard]] constexpr auto p() const noexcept { return m_p; }
|
||||||
constexpr const auto& ram() const noexcept { return m_ram; }
|
[[nodiscard]] constexpr const auto& ram() const noexcept { return m_ram; }
|
||||||
};
|
};
|
||||||
|
@ -16,8 +16,8 @@ public:
|
|||||||
typedef std::tuple<uint16_t, uint8_t, action> event_t; // address, contents, action
|
typedef std::tuple<uint16_t, uint8_t, action> event_t; // address, contents, action
|
||||||
typedef std::vector<event_t> events_t;
|
typedef std::vector<event_t> events_t;
|
||||||
|
|
||||||
static action to_action(std::string value);
|
[[nodiscard]] static action to_action(std::string value);
|
||||||
static std::string to_string(action value);
|
[[nodiscard]] static std::string to_string(action value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
@ -31,8 +31,8 @@ public:
|
|||||||
test_t(const boost::json::object& serialised);
|
test_t(const boost::json::object& serialised);
|
||||||
test_t(const boost::json::value& serialised);
|
test_t(const boost::json::value& serialised);
|
||||||
|
|
||||||
constexpr const auto& name() const noexcept { return m_name; }
|
[[nodiscard]] constexpr const auto& name() const noexcept { return m_name; }
|
||||||
constexpr const auto& initial_state() const noexcept { return m_initial_state; }
|
[[nodiscard]] constexpr const auto& initial_state() const noexcept { return m_initial_state; }
|
||||||
constexpr const auto& final_state() const noexcept { return m_final_state; }
|
[[nodiscard]] constexpr const auto& final_state() const noexcept { return m_final_state; }
|
||||||
constexpr const auto& cycles() const noexcept { return m_cycles; }
|
[[nodiscard]] constexpr const auto& cycles() const noexcept { return m_cycles; }
|
||||||
};
|
};
|
Loading…
x
Reference in New Issue
Block a user