2021-10-10 20:26:30 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <tuple>
|
2021-10-11 13:59:23 +00:00
|
|
|
|
|
|
|
#ifdef USE_BOOST_JSON
|
|
|
|
# include <boost/json.hpp>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef USE_NLOHMANN_JSON
|
|
|
|
# include "nlohmann/json.hpp"
|
|
|
|
#endif
|
2021-10-10 20:26:30 +00:00
|
|
|
|
|
|
|
#include "state_t.h"
|
|
|
|
#include "json_t.h"
|
|
|
|
|
|
|
|
class test_t final : public json_t {
|
|
|
|
public:
|
|
|
|
enum class action { read, write };
|
|
|
|
|
|
|
|
typedef std::tuple<uint16_t, uint8_t, action> event_t; // address, contents, action
|
|
|
|
typedef std::vector<event_t> events_t;
|
|
|
|
|
2021-10-11 09:43:33 +00:00
|
|
|
[[nodiscard]] static action to_action(std::string value);
|
|
|
|
[[nodiscard]] static std::string to_string(action value);
|
2021-10-10 20:26:30 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::string m_name;
|
|
|
|
state_t m_initial_state;
|
|
|
|
state_t m_final_state;
|
|
|
|
events_t m_cycles;
|
|
|
|
|
2021-10-11 13:59:23 +00:00
|
|
|
#ifdef USE_BOOST_JSON
|
2021-10-10 20:26:30 +00:00
|
|
|
void initialise(const boost::json::object& serialised);
|
2021-10-11 13:59:23 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef USE_NLOHMANN_JSON
|
|
|
|
void initialise(const nlohmann::json& serialised);
|
|
|
|
#endif
|
2021-10-10 20:26:30 +00:00
|
|
|
|
|
|
|
public:
|
2021-10-11 13:59:23 +00:00
|
|
|
|
|
|
|
#ifdef USE_BOOST_JSON
|
2021-10-10 20:26:30 +00:00
|
|
|
test_t(const boost::json::object& serialised);
|
|
|
|
test_t(const boost::json::value& serialised);
|
2021-10-11 13:59:23 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef USE_NLOHMANN_JSON
|
|
|
|
test_t(const nlohmann::json& serialised);
|
|
|
|
#endif
|
2021-10-10 20:26:30 +00:00
|
|
|
|
2021-10-11 09:43:33 +00:00
|
|
|
[[nodiscard]] constexpr const auto& name() const noexcept { return m_name; }
|
|
|
|
[[nodiscard]] constexpr const auto& initial_state() const noexcept { return m_initial_state; }
|
|
|
|
[[nodiscard]] constexpr const auto& final_state() const noexcept { return m_final_state; }
|
|
|
|
[[nodiscard]] constexpr const auto& cycles() const noexcept { return m_cycles; }
|
2021-10-10 20:26:30 +00:00
|
|
|
};
|