aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/testing
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-02-19 21:36:19 +0100
committer hop311 <hop3114@gmail.com>2024-02-19 21:56:05 +0100
commite5a7ddfa0aeb8f62e2b53f111122c1c51c03dabc (patch)
treed55471ba1dd0a487e14e2ab18a3c4e3e2d0140ad /src/openvic-simulation/testing
parent35e5f7828a41736194362186ad4f946fad5964d1 (diff)
Fixed point rounding functions and sources cleanup
Diffstat (limited to 'src/openvic-simulation/testing')
-rw-r--r--src/openvic-simulation/testing/Requirement.cpp8
-rw-r--r--src/openvic-simulation/testing/Requirement.hpp12
-rw-r--r--src/openvic-simulation/testing/TestScript.cpp2
-rw-r--r--src/openvic-simulation/testing/TestScript.hpp4
-rw-r--r--src/openvic-simulation/testing/test_scripts/A_001_file_tests.cpp3
-rw-r--r--src/openvic-simulation/testing/test_scripts/A_002_economy_tests.cpp3
-rw-r--r--src/openvic-simulation/testing/test_scripts/A_003_military_unit_tests.cpp3
-rw-r--r--src/openvic-simulation/testing/test_scripts/A_004_networking_tests.cpp3
-rw-r--r--src/openvic-simulation/testing/test_scripts/A_005_nation_tests.cpp3
-rw-r--r--src/openvic-simulation/testing/test_scripts/A_006_politics_tests.cpp3
10 files changed, 26 insertions, 18 deletions
diff --git a/src/openvic-simulation/testing/Requirement.cpp b/src/openvic-simulation/testing/Requirement.cpp
index e7d03e5..eb48f5b 100644
--- a/src/openvic-simulation/testing/Requirement.cpp
+++ b/src/openvic-simulation/testing/Requirement.cpp
@@ -6,3 +6,11 @@ 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_target_value(std::string_view new_target_value) {
+ target_value = new_target_value;
+}
+
+void Requirement::set_actual_value(std::string_view new_actual_value) {
+ actual_value = new_actual_value;
+}
diff --git a/src/openvic-simulation/testing/Requirement.hpp b/src/openvic-simulation/testing/Requirement.hpp
index e91fa79..85a1573 100644
--- a/src/openvic-simulation/testing/Requirement.hpp
+++ b/src/openvic-simulation/testing/Requirement.hpp
@@ -7,15 +7,15 @@ namespace OpenVic {
class Requirement {
// Loaded during construction
- std::string PROPERTY_RW(id);
- std::string PROPERTY_RW(text);
- std::string PROPERTY_RW(acceptance_criteria);
+ std::string PROPERTY(id);
+ std::string PROPERTY(text);
+ std::string PROPERTY(acceptance_criteria);
bool PROPERTY(pass);
bool PROPERTY_RW(tested);
// Initialised and used during script execution
- std::string PROPERTY_RW(target_value);
- std::string PROPERTY_RW(actual_value);
+ std::string PROPERTY(target_value);
+ std::string PROPERTY(actual_value);
public:
Requirement(std::string in_id, std::string in_text, std::string in_acceptance_criteria) {
@@ -27,5 +27,7 @@ namespace OpenVic {
}
void set_pass(bool in_pass);
+ void set_target_value(std::string_view new_target_value);
+ void set_actual_value(std::string_view new_actual_value);
};
}
diff --git a/src/openvic-simulation/testing/TestScript.cpp b/src/openvic-simulation/testing/TestScript.cpp
index ab0bfb9..13858fb 100644
--- a/src/openvic-simulation/testing/TestScript.cpp
+++ b/src/openvic-simulation/testing/TestScript.cpp
@@ -2,6 +2,8 @@
using namespace OpenVic;
+TestScript::TestScript(std::string_view new_script_name) : script_name { new_script_name } {}
+
// Getters
std::vector<Requirement*> TestScript::get_requirements() {
return requirements;
diff --git a/src/openvic-simulation/testing/TestScript.hpp b/src/openvic-simulation/testing/TestScript.hpp
index b41246e..fdf23a5 100644
--- a/src/openvic-simulation/testing/TestScript.hpp
+++ b/src/openvic-simulation/testing/TestScript.hpp
@@ -10,9 +10,11 @@ namespace OpenVic {
std::vector<Requirement*> requirements = std::vector<Requirement*>();
GameManager* PROPERTY_RW(game_manager);
- std::string PROPERTY_RW(script_name);
+ std::string PROPERTY(script_name);
public:
+ TestScript(std::string_view new_script_name);
+
// expects an overriden method that performs arbitrary code execution
// so that each script uniquely performs tests
// for both requirement adding to script and to execute code
diff --git a/src/openvic-simulation/testing/test_scripts/A_001_file_tests.cpp b/src/openvic-simulation/testing/test_scripts/A_001_file_tests.cpp
index e24d44c..213da76 100644
--- a/src/openvic-simulation/testing/test_scripts/A_001_file_tests.cpp
+++ b/src/openvic-simulation/testing/test_scripts/A_001_file_tests.cpp
@@ -5,8 +5,7 @@ namespace OpenVic {
class A_001_file_tests : public TestScript {
public:
- A_001_file_tests() {
- set_script_name("A_001_file_tests");
+ A_001_file_tests() : TestScript { "A_001_file_tests" } {
add_requirements();
}
diff --git a/src/openvic-simulation/testing/test_scripts/A_002_economy_tests.cpp b/src/openvic-simulation/testing/test_scripts/A_002_economy_tests.cpp
index 4bff710..e811144 100644
--- a/src/openvic-simulation/testing/test_scripts/A_002_economy_tests.cpp
+++ b/src/openvic-simulation/testing/test_scripts/A_002_economy_tests.cpp
@@ -5,8 +5,7 @@ namespace OpenVic {
class A_002_economy_tests : public TestScript {
public:
- A_002_economy_tests() {
- set_script_name("A_002_economy_tests");
+ A_002_economy_tests() : TestScript { "A_002_economy_tests" } {
add_requirements();
}
diff --git a/src/openvic-simulation/testing/test_scripts/A_003_military_unit_tests.cpp b/src/openvic-simulation/testing/test_scripts/A_003_military_unit_tests.cpp
index cf572d0..b61abb4 100644
--- a/src/openvic-simulation/testing/test_scripts/A_003_military_unit_tests.cpp
+++ b/src/openvic-simulation/testing/test_scripts/A_003_military_unit_tests.cpp
@@ -5,8 +5,7 @@ namespace OpenVic {
class A_003_military_unit_tests : public TestScript {
public:
- A_003_military_unit_tests() {
- set_script_name("A_003_military_unit_tests");
+ A_003_military_unit_tests() : TestScript { "A_003_military_unit_tests" } {
add_requirements();
}
diff --git a/src/openvic-simulation/testing/test_scripts/A_004_networking_tests.cpp b/src/openvic-simulation/testing/test_scripts/A_004_networking_tests.cpp
index 0e05540..984a3c2 100644
--- a/src/openvic-simulation/testing/test_scripts/A_004_networking_tests.cpp
+++ b/src/openvic-simulation/testing/test_scripts/A_004_networking_tests.cpp
@@ -5,8 +5,7 @@ namespace OpenVic {
class A_004_networking_tests : public TestScript {
public:
- A_004_networking_tests() {
- set_script_name("A_004_networking_tests");
+ A_004_networking_tests() : TestScript { "A_004_networking_tests" } {
add_requirements();
}
diff --git a/src/openvic-simulation/testing/test_scripts/A_005_nation_tests.cpp b/src/openvic-simulation/testing/test_scripts/A_005_nation_tests.cpp
index 6f91ac2..bfa8a59 100644
--- a/src/openvic-simulation/testing/test_scripts/A_005_nation_tests.cpp
+++ b/src/openvic-simulation/testing/test_scripts/A_005_nation_tests.cpp
@@ -5,8 +5,7 @@ namespace OpenVic {
class A_005_nation_tests : public TestScript {
public:
- A_005_nation_tests() {
- set_script_name("A_005_nation_tests");
+ A_005_nation_tests() : TestScript { "A_005_nation_tests" } {
add_requirements();
}
diff --git a/src/openvic-simulation/testing/test_scripts/A_006_politics_tests.cpp b/src/openvic-simulation/testing/test_scripts/A_006_politics_tests.cpp
index 091075c..f9e93d9 100644
--- a/src/openvic-simulation/testing/test_scripts/A_006_politics_tests.cpp
+++ b/src/openvic-simulation/testing/test_scripts/A_006_politics_tests.cpp
@@ -5,8 +5,7 @@ namespace OpenVic {
class A_006_politics_tests : public TestScript {
public:
- A_006_politics_tests() {
- set_script_name("A_006_politics_tests");
+ A_006_politics_tests() : TestScript { "A_006_politics_tests" } {
add_requirements();
}