aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/testing
diff options
context:
space:
mode:
author zaaarf <zaaarf@proton.me>2023-11-22 17:16:34 +0100
committer zaaarf <zaaarf@proton.me>2023-11-22 17:16:34 +0100
commit1683859e333f98fb63f1c72d926bb366a3b89f0b (patch)
treee11dde918a7f1f228d3383ba8f9287385e43b4f5 /src/openvic-simulation/testing
parent5c6caf6fbb7c606f4ebe0c397cc15c97d776f13d (diff)
chore: use PROPERTY and its variants when possible
Diffstat (limited to 'src/openvic-simulation/testing')
-rw-r--r--src/openvic-simulation/testing/Requirement.cpp42
-rw-r--r--src/openvic-simulation/testing/Requirement.hpp33
-rw-r--r--src/openvic-simulation/testing/TestScript.cpp12
-rw-r--r--src/openvic-simulation/testing/TestScript.hpp8
4 files changed, 12 insertions, 83 deletions
diff --git a/src/openvic-simulation/testing/Requirement.cpp b/src/openvic-simulation/testing/Requirement.cpp
index 99a29de..e7d03e5 100644
--- a/src/openvic-simulation/testing/Requirement.cpp
+++ b/src/openvic-simulation/testing/Requirement.cpp
@@ -2,49 +2,7 @@
using namespace OpenVic;
-// Getters
-std::string Requirement::get_id() {
- return id;
-}
-std::string Requirement::get_text() {
- return text;
-}
-std::string Requirement::get_acceptance_criteria() {
- return acceptance_criteria;
-}
-bool Requirement::get_pass() {
- return pass;
-}
-bool Requirement::get_tested() {
- return tested;
-}
-std::string Requirement::get_target_value() {
- return target_value;
-}
-std::string Requirement::get_actual_value() {
- return actual_value;
-}
-
-// Setters
-void Requirement::set_id(std::string in_id) {
- id = in_id;
-}
-void Requirement::set_text(std::string in_text) {
- text = in_text;
-}
-void Requirement::set_acceptance_criteria(std::string in_acceptance_criteria) {
- acceptance_criteria = in_acceptance_criteria;
-}
void Requirement::set_pass(bool in_pass) {
pass = in_pass;
set_tested(true); // Ever setting a pass condition implies it has been tested
}
-void Requirement::set_tested(bool in_tested) {
- tested = in_tested;
-}
-void Requirement::set_target_value(std::string in_target_value) {
- target_value = in_target_value;
-}
-void Requirement::set_actual_value(std::string in_actual_value) {
- actual_value = in_actual_value;
-}
diff --git a/src/openvic-simulation/testing/Requirement.hpp b/src/openvic-simulation/testing/Requirement.hpp
index 20dad3d..e91fa79 100644
--- a/src/openvic-simulation/testing/Requirement.hpp
+++ b/src/openvic-simulation/testing/Requirement.hpp
@@ -1,44 +1,31 @@
#pragma once
#include <string>
+#include "openvic-simulation/utility/Getters.hpp"
namespace OpenVic {
class Requirement {
// Loaded during construction
- std::string id;
- std::string text;
- std::string acceptance_criteria;
- bool pass = false; // Explicitly false to begin
- bool tested = false;
+ std::string PROPERTY_RW(id);
+ std::string PROPERTY_RW(text);
+ std::string PROPERTY_RW(acceptance_criteria);
+ bool PROPERTY(pass);
+ bool PROPERTY_RW(tested);
// Initialised and used during script execution
- std::string target_value;
- std::string actual_value;
+ std::string PROPERTY_RW(target_value);
+ std::string PROPERTY_RW(actual_value);
public:
Requirement(std::string in_id, std::string in_text, std::string in_acceptance_criteria) {
id = in_id;
text = in_text;
acceptance_criteria = in_acceptance_criteria;
+ pass = false; // Explicitly false to begin
+ tested = false;
}
- // Getters
- std::string get_id();
- std::string get_text();
- std::string get_acceptance_criteria();
- bool get_pass();
- bool get_tested();
- std::string get_target_value();
- std::string get_actual_value();
-
- // Setters
- void set_id(std::string in_id);
- void set_text(std::string in_text);
- void set_acceptance_criteria(std::string in_acceptance_criteria);
void set_pass(bool in_pass);
- void set_tested(bool in_tested);
- void set_target_value(std::string in_target_value);
- void set_actual_value(std::string in_actual_value);
};
}
diff --git a/src/openvic-simulation/testing/TestScript.cpp b/src/openvic-simulation/testing/TestScript.cpp
index a238fb5..ab0bfb9 100644
--- a/src/openvic-simulation/testing/TestScript.cpp
+++ b/src/openvic-simulation/testing/TestScript.cpp
@@ -44,12 +44,6 @@ std::vector<Requirement*> TestScript::get_untested_requirements() {
}
return untested_requirements;
}
-GameManager* TestScript::get_game_manager() {
- return game_manager;
-}
-std::string TestScript::get_script_name() {
- return script_name;
-}
// Setters
void TestScript::set_requirements(std::vector<Requirement*> in_requirements) {
@@ -58,12 +52,6 @@ void TestScript::set_requirements(std::vector<Requirement*> in_requirements) {
void TestScript::add_requirement(Requirement* req) {
requirements.push_back(req);
}
-void TestScript::set_game_manager(GameManager* in_game_manager) {
- game_manager = in_game_manager;
-}
-void TestScript::set_script_name(std::string in_script_name) {
- script_name = in_script_name;
-}
// Methods
void TestScript::pass_or_fail_req_with_actual_and_target_values(
diff --git a/src/openvic-simulation/testing/TestScript.hpp b/src/openvic-simulation/testing/TestScript.hpp
index bfc2e95..b41246e 100644
--- a/src/openvic-simulation/testing/TestScript.hpp
+++ b/src/openvic-simulation/testing/TestScript.hpp
@@ -9,8 +9,8 @@ namespace OpenVic {
class TestScript {
std::vector<Requirement*> requirements = std::vector<Requirement*>();
- GameManager* game_manager;
- std::string script_name;
+ GameManager* PROPERTY_RW(game_manager);
+ std::string PROPERTY_RW(script_name);
public:
// expects an overriden method that performs arbitrary code execution
@@ -26,14 +26,10 @@ namespace OpenVic {
std::vector<Requirement*> get_passed_requirements();
std::vector<Requirement*> get_failed_requirements();
std::vector<Requirement*> get_untested_requirements();
- GameManager* get_game_manager();
- std::string get_script_name();
// Setters
void set_requirements(std::vector<Requirement*> in_requirements);
void add_requirement(Requirement* req);
- void set_game_manager(GameManager* in_game_manager);
- void set_script_name(std::string in_script_name);
// Methods
void pass_or_fail_req_with_actual_and_target_values(