aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--src/headless/main.cpp8
-rw-r--r--src/openvic-simulation/testing/Requirement.cpp11
-rw-r--r--src/openvic-simulation/testing/Requirement.hpp12
-rw-r--r--src/openvic-simulation/testing/TestScript.cpp43
-rw-r--r--src/openvic-simulation/testing/TestScript.hpp24
-rw-r--r--src/openvic-simulation/testing/Testing.cpp63
-rw-r--r--src/openvic-simulation/testing/Testing.hpp24
-rw-r--r--src/openvic-simulation/testing/test_scripts/A_001_file_tests.cpp76
-rw-r--r--src/openvic-simulation/testing/test_scripts/A_002_economy_tests.cpp212
-rw-r--r--src/openvic-simulation/testing/test_scripts/A_003_military_unit_tests.cpp4
-rw-r--r--src/openvic-simulation/testing/test_scripts/A_004_networking_tests.cpp4
-rw-r--r--src/openvic-simulation/testing/test_scripts/A_005_nation_tests.cpp4
-rw-r--r--src/openvic-simulation/testing/test_scripts/A_006_politics_tests.cpp4
14 files changed, 312 insertions, 180 deletions
diff --git a/.gitignore b/.gitignore
index ecc9c7e..209b874 100644
--- a/.gitignore
+++ b/.gitignore
@@ -80,4 +80,5 @@ bin/*
# scons stuff
.cache
-compile_commands.json \ No newline at end of file
+compile_commands.json
+src/openvic-simulation/testing/test_results/results.txt
diff --git a/src/headless/main.cpp b/src/headless/main.cpp
index 011c465..04728b6 100644
--- a/src/headless/main.cpp
+++ b/src/headless/main.cpp
@@ -52,8 +52,12 @@ static bool headless_load(Dataloader::path_vector_t const& roots) {
ret = false;
}
- Testing testing { game_manager };
- std::cout << "\nTesting loaded\n" << std::endl;
+
+ Testing testing = Testing(&game_manager);
+ std::cout << std::endl << "Testing Loaded" << std::endl << std::endl;
+ testing.execute_all_scripts();
+ testing.report_results();
+ std::cout << "Testing Executed" << std::endl << std::endl;
return ret;
}
diff --git a/src/openvic-simulation/testing/Requirement.cpp b/src/openvic-simulation/testing/Requirement.cpp
index 4c46f00..d99153a 100644
--- a/src/openvic-simulation/testing/Requirement.cpp
+++ b/src/openvic-simulation/testing/Requirement.cpp
@@ -7,9 +7,18 @@ 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; }
+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 aeb36e7..caea5c6 100644
--- a/src/openvic-simulation/testing/Requirement.hpp
+++ b/src/openvic-simulation/testing/Requirement.hpp
@@ -5,10 +5,16 @@ 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;
+
+ // Initialised and used during script execution
+ std::string target_value;
+ std::string actual_value;
public:
@@ -23,11 +29,17 @@ namespace OpenVic {
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 7652fa5..d9affae 100644
--- a/src/openvic-simulation/testing/TestScript.cpp
+++ b/src/openvic-simulation/testing/TestScript.cpp
@@ -3,29 +3,40 @@
using namespace OpenVic;
// Getters
-std::vector<Requirement> TestScript::get_requirements() { return requirements; }
-Requirement TestScript::get_requirement_at_index(int index) { return requirements[index]; }
-Requirement TestScript::get_requirement_by_id(std::string id) {
- for (int i = 0; i < requirements.size(); i++) {
- if (requirements[i].get_id() == id) return requirements[i];
+std::vector<Requirement*> TestScript::get_requirements() { return requirements; }
+Requirement* TestScript::get_requirement_at_index(int index) { return requirements[index]; }
+Requirement* TestScript::get_requirement_by_id(std::string id) {
+ for (auto req : requirements) {
+ if (req->get_id() == id) return req;
}
- return Requirement("NULL", "NULL", "NULL");
+ return new Requirement("NULL", "NULL", "NULL"); // edge case of failing to find
}
-std::vector<Requirement> TestScript::get_passed_requirements() {
- std::vector<Requirement> passed_requirements = std::vector<Requirement>();
- for (int i = 0; i < requirements.size(); i++) {
- if (requirements[i].get_pass()) passed_requirements.push_back(requirements[i]);
+std::vector<Requirement*> TestScript::get_passed_requirements() {
+ std::vector<Requirement*> passed_requirements = std::vector<Requirement*>();
+ for (auto req : requirements) {
+ if (req->get_pass()) passed_requirements.push_back(req);
}
return passed_requirements;
}
-std::vector<Requirement> TestScript::get_failed_requirements() {
- std::vector<Requirement> failed_requirements = std::vector<Requirement>();
- for (int i = 0; i < requirements.size(); i++) {
- if (!requirements[i].get_pass()) failed_requirements.push_back(requirements[i]);
+std::vector<Requirement*> TestScript::get_failed_requirements() {
+ std::vector<Requirement*> failed_requirements = std::vector<Requirement*>();
+ for (auto req : requirements) {
+ if (!req->get_pass() && req->get_tested()) failed_requirements.push_back(req);
}
return failed_requirements;
}
+std::vector<Requirement*> TestScript::get_untested_requirements() {
+ std::vector<Requirement*> untested_requirements = std::vector<Requirement*>();
+ for (auto req : requirements) {
+ if (!req->get_tested()) untested_requirements.push_back(req);
+ }
+ 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) { requirements = in_requirements; }
-void TestScript::add_requirement(Requirement req) { requirements.push_back(req); }
+void TestScript::set_requirements(std::vector<Requirement*> in_requirements) { requirements = 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; }
diff --git a/src/openvic-simulation/testing/TestScript.hpp b/src/openvic-simulation/testing/TestScript.hpp
index c41767b..874e083 100644
--- a/src/openvic-simulation/testing/TestScript.hpp
+++ b/src/openvic-simulation/testing/TestScript.hpp
@@ -1,12 +1,15 @@
#pragma once
#include <testing/Requirement.hpp>
#include <vector>
+#include <GameManager.hpp>
namespace OpenVic {
class TestScript {
- std::vector<Requirement> requirements = std::vector<Requirement>();
+ std::vector<Requirement*> requirements = std::vector<Requirement*>();
+ GameManager* game_manager;
+ std::string script_name;
public:
@@ -17,14 +20,19 @@ namespace OpenVic {
virtual void execute_script() = 0;
// Getters
- std::vector<Requirement> get_requirements();
- Requirement get_requirement_at_index(int index);
- Requirement get_requirement_by_id(std::string id);
- std::vector<Requirement> get_passed_requirements();
- std::vector<Requirement> get_failed_requirements();
+ std::vector<Requirement*> get_requirements();
+ Requirement* get_requirement_at_index(int index);
+ Requirement* get_requirement_by_id(std::string id);
+ 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_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);
};
}
diff --git a/src/openvic-simulation/testing/Testing.cpp b/src/openvic-simulation/testing/Testing.cpp
index fcfe2cc..4d3d9ea 100644
--- a/src/openvic-simulation/testing/Testing.cpp
+++ b/src/openvic-simulation/testing/Testing.cpp
@@ -1,15 +1,10 @@
#include <testing/Testing.hpp>
#include <testing/TestScript.hpp>
+#include <fstream>
using namespace OpenVic;
-Testing::Testing(GameManager& g_manager)
- : game_manager { g_manager },
- map { g_manager.get_map() },
- building_manager { g_manager.get_building_manager() },
- good_manager { g_manager.get_good_manager() },
- pop_manager { g_manager.get_pop_manager() },
- clock { g_manager.get_clock() } {
+Testing::Testing(GameManager* game_manager) {
// Constructor for the tests will add requirements
// Then execute the script
@@ -25,6 +20,10 @@ Testing::Testing(GameManager& g_manager)
test_scripts.push_back(a_005_nation_tests);
A_006_politics_tests* a_006_politics_tests = new A_006_politics_tests();
test_scripts.push_back(a_006_politics_tests);
+
+ for (int i = 0; i < test_scripts.size(); i++) {
+ test_scripts[i]->set_game_manager(game_manager);
+ }
}
Testing::~Testing() {
@@ -33,10 +32,58 @@ Testing::~Testing() {
}
}
-void Testing::report_results() {
+void Testing::execute_all_scripts() {
for (int i = 0; i < test_scripts.size(); i++) {
+ test_scripts[i]->execute_script();
+ }
+}
+
+void Testing::report_results() {
+ std::ofstream test_results;
+ // _mkdir("..\\src\\openvic - simulation\\testing\\test_results"); - replace with compatible version (boost?)
+ test_results.open("..\\src\\openvic-simulation\\testing\\test_results\\results.txt");
+ for (auto test_script : test_scripts) {
+ std::vector<OpenVic::Requirement*> reqs = test_script->get_requirements();
+ std::vector<OpenVic::Requirement*> passed_reqs = test_script->get_passed_requirements();
+ std::vector<OpenVic::Requirement*> failed_reqs = test_script->get_failed_requirements();
+ std::vector<OpenVic::Requirement*> untested_reqs = test_script->get_untested_requirements();
+
+ test_results << test_script->get_script_name() << ":" << std::endl;
+ test_results << "\t" << "Requirements for Test" << std::endl;
+ test_results << "\t";
+ for (auto req : reqs) {
+ test_results << req->get_id() << " ";
+ }
+ if (reqs.size() < 1) test_results << "None";
+ test_results << std::endl << std::endl;
+
+ test_results << "\t"<< "Passed Requirements" << std::endl;
+ test_results << "\t";
+ for (auto req : passed_reqs) {
+ test_results << req->get_id() << " ";
+ }
+ if (passed_reqs.size() < 1) test_results << "None";
+ test_results << std::endl << std::endl;
+
+ test_results << "\t" << "Failed Requirements" << std::endl;
+ test_results << "\t";
+ for (auto req : failed_reqs) {
+ test_results << req->get_id() << " ";
+ }
+ if (failed_reqs.size() < 1) test_results << "None";
+ test_results << std::endl << std::endl;
+
+ test_results << "\t" << "Untested Requirements" << std::endl;
+ test_results << "\t";
+ for (auto req : untested_reqs) {
+ test_results << req->get_id() << " ";
+ }
+ if (untested_reqs.size() < 1) test_results << "None";
+ test_results << std::endl << std::endl;
+ test_results << std::endl<< std::endl;
}
+ test_results.close();
// Create Summary File
diff --git a/src/openvic-simulation/testing/Testing.hpp b/src/openvic-simulation/testing/Testing.hpp
index 35e8a96..90c32db 100644
--- a/src/openvic-simulation/testing/Testing.hpp
+++ b/src/openvic-simulation/testing/Testing.hpp
@@ -16,29 +16,13 @@ namespace OpenVic {
class Testing {
public:
- GameManager& game_manager;
- Map& map;
- BuildingManager& building_manager;
- GoodManager& good_manager;
- PopManager& pop_manager;
- GameAdvancementHook& clock;
- std::vector<TestScript*> test_scripts = std::vector<TestScript*>();
-
- //// Prototype test script
- //const BuildingType* building_type = building_manager->get_building_type_by_identifier("building_fort");
- //std::cout << "building_fort"
- // << " build time is " << building_type->get_build_time() << std::endl;
- //std::cout << "building_fort"
- // << " identifier is " << building_type->get_identifier() << std::endl;
- //std::cout << "building_fort"
- // << " max level is " << int(building_type->get_max_level()) << std::endl;
- //for (const auto& good : good_manager->get_goods())
- // std::cout << good.get_identifier() << " price = " << good.get_base_price() << std::endl;
-
- Testing(GameManager& g_manager);
+ Testing(GameManager* game_manager);
~Testing();
+ std::vector<TestScript*> test_scripts = std::vector<TestScript*>();
+
+ void execute_all_scripts();
void report_results();
};
}
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 2748d2d..4a16c31 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
@@ -1,77 +1,93 @@
-# pragma once
# include <testing/TestScript.hpp>
+# include <GameManager.hpp>
namespace OpenVic {
class A_001_file_tests : public TestScript {
public:
A_001_file_tests() {
+ set_script_name("A_001_file_tests");
add_requirements();
- execute_script();
}
void add_requirements() {
- Requirement FS_44 = Requirement("FS_44",
+ Requirement* FS_44 = new Requirement("FS_44",
"The icon for the Canned Food good shall be loaded from the R/art/economy/goods folder with the filename Canned Food.png",
"The icon for the Canned Food good has been loaded into the program");
add_requirement(FS_44);
- Requirement FS_48 = Requirement("FS_48",
+ Requirement* FS_48 = new Requirement("FS_48",
"The icon for the Coal good shall be loaded from the R/art/economy/goods folder with the filename Coal.png",
"The icon for the Coal good has been loaded into the program");
add_requirement(FS_48);
- Requirement FS_61 = Requirement("FS_61",
+ Requirement* FS_61 = new Requirement("FS_61",
"The icon for the Grain good shall be loaded from the R/art/economy/goods folder with the filename Grain.png",
"The icon for the Grain good has been loaded into the program");
add_requirement(FS_61);
- Requirement FS_62 = Requirement("FS_62",
+ Requirement* FS_62 = new Requirement("FS_62",
"The icon for the Iron good shall be loaded from the R/art/economy/goods folder with the filename Iron.png",
"The icon for the Iron good has been loaded into the program");
add_requirement(FS_62);
- Requirement FS_63 = Requirement("FS_63",
+ Requirement* FS_63 = new Requirement("FS_63",
"The icon for the Liquor good shall be loaded from the R/art/economy/goods folder with the filename Liquor.png",
"The icon for the Liquor good has been loaded into the program");
add_requirement(FS_63);
- Requirement FS_67 = Requirement("FS_67",
+ Requirement* FS_67 = new Requirement("FS_67",
"The icon for the Machine Parts good shall be loaded from the R/art/economy/goods folder with the filename Machine Parts.png",
"The icon for the Machine Parts good has been loaded into the program");
add_requirement(FS_67);
- Requirement FS_86 = Requirement("FS_86",
+ Requirement* FS_86 = new Requirement("FS_86",
"The icon for the Wool good shall be loaded from the R/art/economy/goods folder with the filename Wool.png",
"The icon for the Wool good has been loaded into the program");
add_requirement(FS_86);
- Requirement FS_24 = Requirement("FS_24",
+ Requirement* FS_2 = new Requirement("FS_2",
+ "User provided data shall be saved to an 'OpenVic' folder, located following platform convention",
+ "User data is saved to the correct place");
+ add_requirement(FS_2);
+ Requirement* FS_20 = new Requirement("FS_20",
+ "On Windows, user provided data shall be saved by default to '%APPDATA%/OpenVic/'",
+ "User data is saved to the correct place");
+ add_requirement(FS_20);
+ Requirement* FS_21 = new Requirement("FS_21",
+ "On Linux, user provided data shall be saved by default to '~/.local/share/OpenVic/'",
+ "User data is saved to the correct place");
+ add_requirement(FS_21);
+ Requirement* FS_22 = new Requirement("FS_22",
+ "On macOS, user provided data shall be saved by default to '~/Library/Application Support/OpenVic/'",
+ "User data is saved to the correct place");
+ add_requirement(FS_22);
+ Requirement* FS_24 = new Requirement("FS_24",
"All .csv files in the locale folder shall contain translation keys and translations",
"No errant files in locale directory");
add_requirement(FS_24);
- Requirement FS_17 = Requirement("FS_17",
+ Requirement* FS_17 = new Requirement("FS_17",
"List of available locales are loaded from R/localisation/ directory",
"Locales loaded correctly");
add_requirement(FS_17);
- Requirement FS_333 = Requirement("FS_333",
+ Requirement* FS_333 = new Requirement("FS_333",
"The map's provinces shall be defined by unique colours in 'R/map/provinces.bmp'",
"The unique colours of 'R/map/provinces.bmp' define provinces");
add_requirement(FS_333);
- Requirement FS_335 = Requirement("FS_335",
+ Requirement* FS_335 = new Requirement("FS_335",
"Unique province IDs shall be associated with their unique colours in 'R/map/definition.csv'",
"'R/map/definition.csv' associates every unique colour used to define a province with a unique ID");
add_requirement(FS_335);
- Requirement FS_334 = Requirement("FS_334",
+ Requirement* FS_334 = new Requirement("FS_334",
"Water provinces shall be defined by a list of their IDs in 'R/map/default.map'",
"'R/map/default.map' contains a list of province IDs which are used to define water provinces");
add_requirement(FS_334);
- Requirement FS_338 = Requirement("FS_338",
+ Requirement* FS_338 = new Requirement("FS_338",
"The image for the minimap background shall be loaded from the R/art/ui folder with the filename minimap.png",
"The image for the minimap background has been loaded into the program");
add_requirement(FS_338);
- Requirement FS_343 = Requirement("FS_343",
+ Requirement* FS_343 = new Requirement("FS_343",
"The textures making up the cosmetic terrain map shall be loaded from the R/art/terrain folder",
"The textures making up the cosmetic terrain map have been loaded into the program");
add_requirement(FS_343);
- Requirement FS_341 = Requirement("FS_341",
+ Requirement* FS_341 = new Requirement("FS_341",
"State areas shall be defined by lists of province IDs in 'R/map/region.txt'",
"'R/map/region.txt' defines state areas with lists of province IDs");
add_requirement(FS_341);
- Requirement SND_10 = Requirement("SND_10",
+ Requirement* SND_10 = new Requirement("SND_10",
"SFX shall be refered to by their filename, without the extension",
"Sound effects are identified by their filename without extension");
add_requirement(SND_10);
@@ -120,6 +136,30 @@ namespace OpenVic {
// TODO: Write test steps for FS_86...
+ // FS_2
+ // User provided data shall be saved to an 'OpenVic' folder, located following platform convention
+ // User data is saved to the correct place
+
+ // TODO: Write test steps for FS_2...
+
+ // FS_20
+ // On Windows, user provided data shall be saved by default to '%APPDATA%/OpenVic/'
+ // User data is saved to the correct place
+
+ // TODO: Write test steps for FS_20...
+
+ // FS_21
+ // On Linux, user provided data shall be saved by default to '~/.local/share/OpenVic/'
+ // User data is saved to the correct place
+
+ // TODO: Write test steps for FS_21...
+
+ // FS_22
+ // On macOS, user provided data shall be saved by default to '~/Library/Application Support/OpenVic/'
+ // User data is saved to the correct place
+
+ // TODO: Write test steps for FS_22...
+
// FS_24
// All .csv files in the locale folder shall contain translation keys and translations
// No errant files in locale directory
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 adab342..aa0e59f 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
@@ -1,499 +1,515 @@
-# pragma once
# include <testing/TestScript.hpp>
+# include <GameManager.hpp>
namespace OpenVic {
class A_002_economy_tests : public TestScript {
public:
A_002_economy_tests() {
+ set_script_name("A_002_economy_tests");
add_requirements();
- execute_script();
}
void add_requirements() {
- Requirement ECON_123 = Requirement("ECON_123",
+ Requirement* ECON_123 = new Requirement("ECON_123",
"The base price for Aeroplanes shall be 110",
"The base price of 110 for Aeroplanes can be seen in program output data");
add_requirement(ECON_123);
- Requirement ECON_124 = Requirement("ECON_124",
+ Requirement* ECON_124 = new Requirement("ECON_124",
"The base price for Ammunition shall be 17.5",
"The base price of 17.5 for Ammunition can be seen in program output data");
add_requirement(ECON_124);
- Requirement ECON_125 = Requirement("ECON_125",
+ Requirement* ECON_125 = new Requirement("ECON_125",
"The base price for Artillery shall be 60",
"The base price of 60 for Artillery can be seen in program output data");
add_requirement(ECON_125);
- Requirement ECON_126 = Requirement("ECON_126",
+ Requirement* ECON_126 = new Requirement("ECON_126",
"The base price for Automobiles shall be 70",
"The base price of 70 for Automobiles can be seen in program output data");
add_requirement(ECON_126);
- Requirement ECON_127 = Requirement("ECON_127",
+ Requirement* ECON_127 = new Requirement("ECON_127",
"The base price for Canned Food shall be 16",
"The base price of 16 for Canned Food can be seen in program output data");
add_requirement(ECON_127);
- Requirement ECON_128 = Requirement("ECON_128",
+ Requirement* ECON_128 = new Requirement("ECON_128",
"The base price for Cattle shall be 2",
"The base price of 2 for Cattle can be seen in program output data");
add_requirement(ECON_128);
- Requirement ECON_129 = Requirement("ECON_129",
+ Requirement* ECON_129 = new Requirement("ECON_129",
"The base price for Cement shall be 16",
"The base price of 16 for Cement can be seen in program output data");
add_requirement(ECON_129);
- Requirement ECON_130 = Requirement("ECON_130",
+ Requirement* ECON_130 = new Requirement("ECON_130",
"The base price for Clipper Convoys shall be 42",
"The base price of 42 for Clipper Convoys can be seen in program output data");
add_requirement(ECON_130);
- Requirement ECON_131 = Requirement("ECON_131",
+ Requirement* ECON_131 = new Requirement("ECON_131",
"The base price for Coal shall be 2.3",
"The base price of 2.3 for Coal can be seen in program output data");
add_requirement(ECON_131);
- Requirement ECON_132 = Requirement("ECON_132",
+ Requirement* ECON_132 = new Requirement("ECON_132",
"The base price for Coffee shall be 2.1",
"The base price of 2.1 for Coffee can be seen in program output data");
add_requirement(ECON_132);
- Requirement ECON_133 = Requirement("ECON_133",
+ Requirement* ECON_133 = new Requirement("ECON_133",
"The base price for Cotton shall be 2",
"The base price of 2 for Cotton can be seen in program output data");
add_requirement(ECON_133);
- Requirement ECON_134 = Requirement("ECON_134",
+ Requirement* ECON_134 = new Requirement("ECON_134",
"The base price for Dye shall be 12",
"The base price of 12 for Dye can be seen in program output data");
add_requirement(ECON_134);
- Requirement ECON_135 = Requirement("ECON_135",
+ Requirement* ECON_135 = new Requirement("ECON_135",
"The base price for Electric Gear shall be 16",
"The base price of 16 for Electric Gear can be seen in program output data");
add_requirement(ECON_135);
- Requirement ECON_136 = Requirement("ECON_136",
+ Requirement* ECON_136 = new Requirement("ECON_136",
"The base price for Explosives shall be 20",
"The base price of 20 for Explosives can be seen in program output data");
add_requirement(ECON_136);
- Requirement ECON_137 = Requirement("ECON_137",
+ Requirement* ECON_137 = new Requirement("ECON_137",
"The base price for Fabric shall be 1.8",
"The base price of 1.8 for Fabric can be seen in program output data");
add_requirement(ECON_137);
- Requirement ECON_138 = Requirement("ECON_138",
+ Requirement* ECON_138 = new Requirement("ECON_138",
"The base price for Fertilizer shall be 10",
"The base price of 10 for Fertilizer can be seen in program output data");
add_requirement(ECON_138);
- Requirement ECON_139 = Requirement("ECON_139",
+ Requirement* ECON_139 = new Requirement("ECON_139",
"The base price for Fish shall be 1.5",
"The base price of 1.5 for Fish can be seen in program output data");
add_requirement(ECON_139);
- Requirement ECON_140 = Requirement("ECON_140",
+ Requirement* ECON_140 = new Requirement("ECON_140",
"The base price for Fruit shall be 1.8",
"The base price of 1.8 for Fruit can be seen in program output data");
add_requirement(ECON_140);
- Requirement ECON_141 = Requirement("ECON_141",
+ Requirement* ECON_141 = new Requirement("ECON_141",
"The base price for Fuel shall be 25",
"The base price of 25 for Fuel can be seen in program output data");
add_requirement(ECON_141);
- Requirement ECON_142 = Requirement("ECON_142",
+ Requirement* ECON_142 = new Requirement("ECON_142",
"The base price for Furniture shall be 4.9",
"The base price of 4.9 for Furniture can be seen in program output data");
add_requirement(ECON_142);
- Requirement ECON_234 = Requirement("ECON_234",
+ Requirement* ECON_234 = new Requirement("ECON_234",
"The base price for Glass shall be 2.9",
"The base price of 2.9 for Glass can be seen in program output data");
add_requirement(ECON_234);
- Requirement ECON_235 = Requirement("ECON_235",
+ Requirement* ECON_235 = new Requirement("ECON_235",
"The base price for Grain shall be 2.2",
"The base price of 2.2 for Grain can be seen in program output data");
add_requirement(ECON_235);
- Requirement ECON_236 = Requirement("ECON_236",
+ Requirement* ECON_236 = new Requirement("ECON_236",
"The base price for Iron shall be 3.5",
"The base price of 3.5 for Iron can be seen in program output data");
add_requirement(ECON_236);
- Requirement ECON_237 = Requirement("ECON_237",
+ Requirement* ECON_237 = new Requirement("ECON_237",
"The base price for Liquor shall be 6.4",
"The base price of 6.4 for Liquor can be seen in program output data");
add_requirement(ECON_237);
- Requirement ECON_238 = Requirement("ECON_238",
+ Requirement* ECON_238 = new Requirement("ECON_238",
"The base price for Lumber shall be 1",
"The base price of 1 for Lumber can be seen in program output data");
add_requirement(ECON_238);
- Requirement ECON_239 = Requirement("ECON_239",
+ Requirement* ECON_239 = new Requirement("ECON_239",
"The base price for Luxury Clothes shall be 65",
"The base price of 65 for Luxury Clothes can be seen in program output data");
add_requirement(ECON_239);
- Requirement ECON_240 = Requirement("ECON_240",
+ Requirement* ECON_240 = new Requirement("ECON_240",
"The base price for Luxury Furniture shall be 59",
"The base price of 59 for Luxury Furniture can be seen in program output data");
add_requirement(ECON_240);
- Requirement ECON_241 = Requirement("ECON_241",
+ Requirement* ECON_241 = new Requirement("ECON_241",
"The base price for Machine Parts shall be 36.5",
"The base price of 36.5 for Machine Parts can be seen in program output data");
add_requirement(ECON_241);
- Requirement ECON_242 = Requirement("ECON_242",
+ Requirement* ECON_242 = new Requirement("ECON_242",
"The base price for Oil shall be 12",
"The base price of 12 for Oil can be seen in program output data");
add_requirement(ECON_242);
- Requirement ECON_243 = Requirement("ECON_243",
+ Requirement* ECON_243 = new Requirement("ECON_243",
"The base price for Opium shall be 3.2",
"The base price of 3.2 for Opium can be seen in program output data");
add_requirement(ECON_243);
- Requirement ECON_244 = Requirement("ECON_244",
+ Requirement* ECON_244 = new Requirement("ECON_244",
"The base price for Paper shall be 3.4",
"The base price of 3.4 for Paper can be seen in program output data");
add_requirement(ECON_244);
- Requirement ECON_245 = Requirement("ECON_245",
+ Requirement* ECON_245 = new Requirement("ECON_245",
"The base price for Precious Metal shall be 8",
"The base price of 8 for Precious Metal can be seen in program output data");
add_requirement(ECON_245);
- Requirement ECON_246 = Requirement("ECON_246",
+ Requirement* ECON_246 = new Requirement("ECON_246",
"The base price for Radios shall be 16",
"The base price of 16 for Radios can be seen in program output data");
add_requirement(ECON_246);
- Requirement ECON_247 = Requirement("ECON_247",
+ Requirement* ECON_247 = new Requirement("ECON_247",
"The base price for Regular Clothes shall be 5.8",
"The base price of 5.8 for Regular Clothes can be seen in program output data");
add_requirement(ECON_247);
- Requirement ECON_248 = Requirement("ECON_248",
+ Requirement* ECON_248 = new Requirement("ECON_248",
"The base price for Rubber shall be 7",
"The base price of 7 for Rubber can be seen in program output data");
add_requirement(ECON_248);
- Requirement ECON_249 = Requirement("ECON_249",
+ Requirement* ECON_249 = new Requirement("ECON_249",
"The base price for Silk shall be 10",
"The base price of 10 for Silk can be seen in program output data");
add_requirement(ECON_249);
- Requirement ECON_250 = Requirement("ECON_250",
+ Requirement* ECON_250 = new Requirement("ECON_250",
"The base price for Small Arms shall be 37",
"The base price of 37 for Small Arms can be seen in program output data");
add_requirement(ECON_250);
- Requirement ECON_251 = Requirement("ECON_251",
+ Requirement* ECON_251 = new Requirement("ECON_251",
"The base price for Steamer Convoys shall be 65",
"The base price of 65 for Steamer Convoys can be seen in program output data");
add_requirement(ECON_251);
- Requirement ECON_252 = Requirement("ECON_252",
+ Requirement* ECON_252 = new Requirement("ECON_252",
"The base price for Steel shall be 4.7",
"The base price of 4.7 for Steel can be seen in program output data");
add_requirement(ECON_252);
- Requirement ECON_253 = Requirement("ECON_253",
+ Requirement* ECON_253 = new Requirement("ECON_253",
"The base price for Sulphur shall be 6",
"The base price of 6 for Sulphur can be seen in program output data");
add_requirement(ECON_253);
- Requirement ECON_254 = Requirement("ECON_254",
+ Requirement* ECON_254 = new Requirement("ECON_254",
"The base price for Tanks shall be 98",
"The base price of 98 for Tanks can be seen in program output data");
add_requirement(ECON_254);
- Requirement ECON_255 = Requirement("ECON_255",
+ Requirement* ECON_255 = new Requirement("ECON_255",
"The base price for Tea shall be 2.6",
"The base price of 2.6 for Tea can be seen in program output data");
add_requirement(ECON_255);
- Requirement ECON_256 = Requirement("ECON_256",
+ Requirement* ECON_256 = new Requirement("ECON_256",
"The base price for Telephones shall be 16",
"The base price of 16 for Telephones can be seen in program output data");
add_requirement(ECON_256);
- Requirement ECON_257 = Requirement("ECON_257",
+ Requirement* ECON_257 = new Requirement("ECON_257",
"The base price for Timber shall be 0.9",
"The base price of 0.9 for Timber can be seen in program output data");
add_requirement(ECON_257);
- Requirement ECON_258 = Requirement("ECON_258",
+ Requirement* ECON_258 = new Requirement("ECON_258",
"The base price for Tobacco shall be 1.1",
"The base price of 1.1 for Tobacco can be seen in program output data");
add_requirement(ECON_258);
- Requirement ECON_259 = Requirement("ECON_259",
+ Requirement* ECON_259 = new Requirement("ECON_259",
"The base price for Tropical Wood shall be 5.4",
"The base price of 5.4 for Tropical Wood can be seen in program output data");
add_requirement(ECON_259);
- Requirement ECON_260 = Requirement("ECON_260",
+ Requirement* ECON_260 = new Requirement("ECON_260",
"The base price for Wine shall be 9.7",
"The base price of 9.7 for Wine can be seen in program output data");
add_requirement(ECON_260);
- Requirement ECON_261 = Requirement("ECON_261",
+ Requirement* ECON_261 = new Requirement("ECON_261",
"The base price for Wool shall be 0.7",
"The base price of 0.7 for Wool can be seen in program output data");
add_requirement(ECON_261);
}
void execute_script() {
+ // Reference of goods by identifier:
+ // ammunition small_arms artillery canned_food barrels aeroplanes cotton dye wool
+ // silk coal sulphur iron timber tropical_wood rubber oil precious_metal steel cement
+ // machine_parts glass fuel fertilizer explosives clipper_convoy steamer_convoy
+ // electric_gear fabric lumber paper cattle fish fruit grain tobacco tea coffee opium
+ // automobiles telephones wine liquor regular_clothes luxury_clothes furniture
+ // luxury_furniture radio
+
// ECON_123
// The base price for Aeroplanes shall be 110
// The base price of 110 for Aeroplanes can be seen in program output data
- // TODO: Write test steps for ECON_123...
+ check_base_price("aeroplanes", "110.0", "ECON_123");
// ECON_124
// The base price for Ammunition shall be 17.5
// The base price of 17.5 for Ammunition can be seen in program output data
- // TODO: Write test steps for ECON_124...
+ check_base_price("ammunition", "17.5", "ECON_124");
// ECON_125
// The base price for Artillery shall be 60
// The base price of 60 for Artillery can be seen in program output data
- // TODO: Write test steps for ECON_125...
+ check_base_price("artillery", "60.0", "ECON_125");
// ECON_126
// The base price for Automobiles shall be 70
// The base price of 70 for Automobiles can be seen in program output data
- // TODO: Write test steps for ECON_126...
+ check_base_price("automobiles", "70.0", "ECON_126");
// ECON_127
// The base price for Canned Food shall be 16
// The base price of 16 for Canned Food can be seen in program output data
- // TODO: Write test steps for ECON_127...
+ check_base_price("canned_food", "16.0", "ECON_127");
// ECON_128
// The base price for Cattle shall be 2
// The base price of 2 for Cattle can be seen in program output data
- // TODO: Write test steps for ECON_128...
+ check_base_price("cattle", "2.0", "ECON_128");
// ECON_129
// The base price for Cement shall be 16
// The base price of 16 for Cement can be seen in program output data
- // TODO: Write test steps for ECON_129...
+ check_base_price("cement", "16.0", "ECON_129");
// ECON_130
// The base price for Clipper Convoys shall be 42
// The base price of 42 for Clipper Convoys can be seen in program output data
- // TODO: Write test steps for ECON_130...
+ check_base_price("clipper_convoy", "42.0", "ECON_130");
// ECON_131
// The base price for Coal shall be 2.3
// The base price of 2.3 for Coal can be seen in program output data
- // TODO: Write test steps for ECON_131...
+ check_base_price("coal", "2.3", "ECON_131");
// ECON_132
// The base price for Coffee shall be 2.1
// The base price of 2.1 for Coffee can be seen in program output data
- // TODO: Write test steps for ECON_132...
+ check_base_price("coffee", "2.1", "ECON_132");
// ECON_133
// The base price for Cotton shall be 2
// The base price of 2 for Cotton can be seen in program output data
- // TODO: Write test steps for ECON_133...
+ check_base_price("cotton", "2.0", "ECON_133");
// ECON_134
// The base price for Dye shall be 12
// The base price of 12 for Dye can be seen in program output data
- // TODO: Write test steps for ECON_134...
+ check_base_price("dye", "12.0", "ECON_134");
// ECON_135
// The base price for Electric Gear shall be 16
// The base price of 16 for Electric Gear can be seen in program output data
- // TODO: Write test steps for ECON_135...
+ check_base_price("electric_gear", "16.0", "ECON_135");
// ECON_136
// The base price for Explosives shall be 20
// The base price of 20 for Explosives can be seen in program output data
- // TODO: Write test steps for ECON_136...
+ check_base_price("explosives", "20.0", "ECON_136");
// ECON_137
// The base price for Fabric shall be 1.8
// The base price of 1.8 for Fabric can be seen in program output data
- // TODO: Write test steps for ECON_137...
+ check_base_price("fabric", "1.8", "ECON_137");
// ECON_138
// The base price for Fertilizer shall be 10
// The base price of 10 for Fertilizer can be seen in program output data
- // TODO: Write test steps for ECON_138...
+ check_base_price("fertilizer", "10.0", "ECON_138");
// ECON_139
// The base price for Fish shall be 1.5
// The base price of 1.5 for Fish can be seen in program output data
- // TODO: Write test steps for ECON_139...
+ check_base_price("fish", "1.5", "ECON_139");
// ECON_140
// The base price for Fruit shall be 1.8
// The base price of 1.8 for Fruit can be seen in program output data
- // TODO: Write test steps for ECON_140...
+ check_base_price("fruit", "1.8", "ECON_140");
// ECON_141
// The base price for Fuel shall be 25
// The base price of 25 for Fuel can be seen in program output data
- // TODO: Write test steps for ECON_141...
+ check_base_price("fuel", "25.0", "ECON_141");
// ECON_142
// The base price for Furniture shall be 4.9
// The base price of 4.9 for Furniture can be seen in program output data
- // TODO: Write test steps for ECON_142...
+ check_base_price("furniture", "4.9", "ECON_142");
// ECON_234
// The base price for Glass shall be 2.9
// The base price of 2.9 for Glass can be seen in program output data
- // TODO: Write test steps for ECON_234...
+ check_base_price("glass", "2.9", "ECON_234");
// ECON_235
// The base price for Grain shall be 2.2
// The base price of 2.2 for Grain can be seen in program output data
- // TODO: Write test steps for ECON_235...
+ check_base_price("grain", "2.2", "ECON_235");
// ECON_236
// The base price for Iron shall be 3.5
// The base price of 3.5 for Iron can be seen in program output data
- // TODO: Write test steps for ECON_236...
+ check_base_price("iron", "3.5", "ECON_236");
// ECON_237
// The base price for Liquor shall be 6.4
// The base price of 6.4 for Liquor can be seen in program output data
- // TODO: Write test steps for ECON_237...
+ check_base_price("liquor", "6.4", "ECON_237");
// ECON_238
// The base price for Lumber shall be 1
// The base price of 1 for Lumber can be seen in program output data
- // TODO: Write test steps for ECON_238...
+ check_base_price("lumber", "1.0", "ECON_238");
// ECON_239
// The base price for Luxury Clothes shall be 65
// The base price of 65 for Luxury Clothes can be seen in program output data
- // TODO: Write test steps for ECON_239...
+ check_base_price("luxury_clothes", "65.0", "ECON_239");
// ECON_240
// The base price for Luxury Furniture shall be 59
// The base price of 59 for Luxury Furniture can be seen in program output data
- // TODO: Write test steps for ECON_240...
+ check_base_price("luxury_furniture", "59.0", "ECON_240");
// ECON_241
// The base price for Machine Parts shall be 36.5
// The base price of 36.5 for Machine Parts can be seen in program output data
- // TODO: Write test steps for ECON_241...
+ check_base_price("machine_parts", "36.5", "ECON_241");
// ECON_242
// The base price for Oil shall be 12
// The base price of 12 for Oil can be seen in program output data
- // TODO: Write test steps for ECON_242...
+ check_base_price("oil", "12.0", "ECON_242");
// ECON_243
// The base price for Opium shall be 3.2
// The base price of 3.2 for Opium can be seen in program output data
- // TODO: Write test steps for ECON_243...
+ check_base_price("opium", "3.2", "ECON_243");
// ECON_244
// The base price for Paper shall be 3.4
// The base price of 3.4 for Paper can be seen in program output data
- // TODO: Write test steps for ECON_244...
+ check_base_price("paper", "3.4", "ECON_244");
// ECON_245
// The base price for Precious Metal shall be 8
// The base price of 8 for Precious Metal can be seen in program output data
- // TODO: Write test steps for ECON_245...
+ check_base_price("precious_metal", "8.0", "ECON_245");
// ECON_246
// The base price for Radios shall be 16
// The base price of 16 for Radios can be seen in program output data
- // TODO: Write test steps for ECON_246...
+ check_base_price("radio", "16.0", "ECON_246");
// ECON_247
// The base price for Regular Clothes shall be 5.8
// The base price of 5.8 for Regular Clothes can be seen in program output data
- // TODO: Write test steps for ECON_247...
+ check_base_price("regular_clothes", "5.8", "ECON_247");
// ECON_248
// The base price for Rubber shall be 7
// The base price of 7 for Rubber can be seen in program output data
- // TODO: Write test steps for ECON_248...
+ check_base_price("rubber", "7.0", "ECON_248");
// ECON_249
// The base price for Silk shall be 10
// The base price of 10 for Silk can be seen in program output data
- // TODO: Write test steps for ECON_249...
+ check_base_price("silk", "10.0", "ECON_249");
// ECON_250
// The base price for Small Arms shall be 37
// The base price of 37 for Small Arms can be seen in program output data
- // TODO: Write test steps for ECON_250...
+ check_base_price("small_arms", "37.0", "ECON_250");
// ECON_251
// The base price for Steamer Convoys shall be 65
// The base price of 65 for Steamer Convoys can be seen in program output data
- // TODO: Write test steps for ECON_251...
+ check_base_price("steamer_convoy", "65.0", "ECON_251");
// ECON_252
// The base price for Steel shall be 4.7
// The base price of 4.7 for Steel can be seen in program output data
- // TODO: Write test steps for ECON_252...
+ check_base_price("steel", "4.7", "ECON_252");
// ECON_253
// The base price for Sulphur shall be 6
// The base price of 6 for Sulphur can be seen in program output data
- // TODO: Write test steps for ECON_253...
+ check_base_price("sulphur", "6.0", "ECON_253");
// ECON_254
// The base price for Tanks shall be 98
// The base price of 98 for Tanks can be seen in program output data
- // TODO: Write test steps for ECON_254...
+ check_base_price("barrels", "98.0", "ECON_254");
// ECON_255
// The base price for Tea shall be 2.6
// The base price of 2.6 for Tea can be seen in program output data
- // TODO: Write test steps for ECON_255...
+ check_base_price("tea", "2.6", "ECON_255");
// ECON_256
// The base price for Telephones shall be 16
// The base price of 16 for Telephones can be seen in program output data
- // TODO: Write test steps for ECON_256...
+ check_base_price("telephones", "16.0", "ECON_256");
// ECON_257
// The base price for Timber shall be 0.9
// The base price of 0.9 for Timber can be seen in program output data
- // TODO: Write test steps for ECON_257...
+ check_base_price("timber", "0.9", "ECON_257");
// ECON_258
// The base price for Tobacco shall be 1.1
// The base price of 1.1 for Tobacco can be seen in program output data
- // TODO: Write test steps for ECON_258...
+ check_base_price("tobacco", "1.1", "ECON_258");
// ECON_259
// The base price for Tropical Wood shall be 5.4
// The base price of 5.4 for Tropical Wood can be seen in program output data
- // TODO: Write test steps for ECON_259...
+ check_base_price("tropical_wood", "5.4", "ECON_259");
// ECON_260
// The base price for Wine shall be 9.7
// The base price of 9.7 for Wine can be seen in program output data
- // TODO: Write test steps for ECON_260...
+ check_base_price("wine", "9.7", "ECON_260");
// ECON_261
// The base price for Wool shall be 0.7
// The base price of 0.7 for Wool can be seen in program output data
- // TODO: Write test steps for ECON_261...
+ check_base_price("wool", "0.7", "ECON_261");
+ }
+ void check_base_price(std::string identifier, std::string value, std::string req_name) {
+ std::string base_price = get_game_manager()->get_good_manager().get_good_by_identifier(identifier)->get_base_price().to_string();
+ Requirement* req = get_requirement_by_id(req_name);
+ req->set_target_value(value);
+ req->set_actual_value(base_price);
+ if (base_price == value) req->set_pass(true);
+ else req->set_pass(false);
}
};
}
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 042e94b..7fd2184 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
@@ -1,13 +1,13 @@
-# pragma once
# include <testing/TestScript.hpp>
+# include <GameManager.hpp>
namespace OpenVic {
class A_003_military_unit_tests : public TestScript {
public:
A_003_military_unit_tests() {
+ set_script_name("A_003_military_unit_tests");
add_requirements();
- execute_script();
}
void 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 926d9b4..5cdc86e 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
@@ -1,13 +1,13 @@
-# pragma once
# include <testing/TestScript.hpp>
+# include <GameManager.hpp>
namespace OpenVic {
class A_004_networking_tests : public TestScript {
public:
A_004_networking_tests() {
+ set_script_name("A_004_networking_tests");
add_requirements();
- execute_script();
}
void 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 027f1bc..494604f 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
@@ -1,13 +1,13 @@
-# pragma once
# include <testing/TestScript.hpp>
+# include <GameManager.hpp>
namespace OpenVic {
class A_005_nation_tests : public TestScript {
public:
A_005_nation_tests() {
+ set_script_name("A_005_nation_tests");
add_requirements();
- execute_script();
}
void 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 c35a827..6fe9ca9 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
@@ -1,13 +1,13 @@
-# pragma once
# include <testing/TestScript.hpp>
+# include <GameManager.hpp>
namespace OpenVic {
class A_006_politics_tests : public TestScript {
public:
A_006_politics_tests() {
+ set_script_name("A_006_politics_tests");
add_requirements();
- execute_script();
}
void add_requirements() {