From c4356fc96da67a02d6a51f0e5114a414542e2243 Mon Sep 17 00:00:00 2001
From: Timon Habenicht <t.habenicht@tu-bs.de>
Date: Wed, 21 Nov 2018 10:57:02 +0100
Subject: [PATCH] adds new Test class

---
 .../Utilities/Test/SimulationObserver.h       | 12 +++++
 .../NumericalTests/Utilities/Test/Test.h      | 25 ++++++++++
 .../NumericalTests/Utilities/Test/TestImp.cpp | 46 +++++++++++++++++++
 .../NumericalTests/Utilities/Test/TestImp.h   | 30 ++++++++++++
 .../Utilities/Test/package.include            |  0
 5 files changed, 113 insertions(+)
 create mode 100644 targets/tests/NumericalTests/Utilities/Test/SimulationObserver.h
 create mode 100644 targets/tests/NumericalTests/Utilities/Test/Test.h
 create mode 100644 targets/tests/NumericalTests/Utilities/Test/TestImp.cpp
 create mode 100644 targets/tests/NumericalTests/Utilities/Test/TestImp.h
 create mode 100644 targets/tests/NumericalTests/Utilities/Test/package.include

diff --git a/targets/tests/NumericalTests/Utilities/Test/SimulationObserver.h b/targets/tests/NumericalTests/Utilities/Test/SimulationObserver.h
new file mode 100644
index 000000000..46e771d74
--- /dev/null
+++ b/targets/tests/NumericalTests/Utilities/Test/SimulationObserver.h
@@ -0,0 +1,12 @@
+#ifndef SIMULATION_OBSERVER_H
+#define SIMULATION_OBSERVER_H
+
+class SimulationObserver
+{
+public:
+	virtual void update() = 0;
+
+private:
+
+};
+#endif 
\ No newline at end of file
diff --git a/targets/tests/NumericalTests/Utilities/Test/Test.h b/targets/tests/NumericalTests/Utilities/Test/Test.h
new file mode 100644
index 000000000..ff3840ca5
--- /dev/null
+++ b/targets/tests/NumericalTests/Utilities/Test/Test.h
@@ -0,0 +1,25 @@
+#ifndef TEST_H
+#define TEST_H
+
+#include "SimulationObserver.h"
+
+#include <memory>
+#include <vector>
+#include <string>
+
+class TestSimulation;
+class SimulationInfo;
+
+class Test : public SimulationObserver 
+{
+public:
+	virtual void update() = 0;
+	virtual void addSimulation(std::shared_ptr< TestSimulation> sim, std::shared_ptr< SimulationInfo> simInfo) = 0;
+	virtual std::string getLogFileOutput() = 0;
+	virtual std::vector< bool> getPassedTests() = 0;
+	virtual void makeOutput() = 0;
+
+private:
+
+};
+#endif 
\ No newline at end of file
diff --git a/targets/tests/NumericalTests/Utilities/Test/TestImp.cpp b/targets/tests/NumericalTests/Utilities/Test/TestImp.cpp
new file mode 100644
index 000000000..0b9df1eba
--- /dev/null
+++ b/targets/tests/NumericalTests/Utilities/Test/TestImp.cpp
@@ -0,0 +1,46 @@
+#include "TestImp.h"
+
+#include "Utilities\TestSimulation\TestSimulation.h"
+
+void TestImp::update()
+{
+	for (int i = 0; i < simulations.size(); i++)
+	{
+		if(simulationRun.at(i) == false)
+		{
+			if (simulations.at(i)->getSimulationRun())
+			{
+				simulationRun.at(i) = true;
+				simResults.at(i) = simulations.at(i)->getSimulationResults();
+			}
+		}
+	}
+
+	if (CheckAllSimulationRun())
+		evaluate();				
+}
+
+void TestImp::addSimulation(std::shared_ptr<TestSimulation> sim, std::shared_ptr< SimulationInfo> simInfo)
+{
+	simulations.push_back(sim);
+	simInfos.push_back(simInfo);
+	simulationRun.push_back(false);
+	simResults.resize(simResults.size() + 1);
+}
+
+TestImp::TestImp()
+{
+	simulationRun.resize(0);
+	simulations.resize(0);
+	simResults.resize(0);
+	simInfos.resize(0);
+}
+
+bool TestImp::CheckAllSimulationRun()
+{
+	for(int i=0; i< simulationRun.size(); i++)
+		if(simulationRun.at(i)==false)
+			return false;
+	
+	return true;
+}
diff --git a/targets/tests/NumericalTests/Utilities/Test/TestImp.h b/targets/tests/NumericalTests/Utilities/Test/TestImp.h
new file mode 100644
index 000000000..9086b97dd
--- /dev/null
+++ b/targets/tests/NumericalTests/Utilities/Test/TestImp.h
@@ -0,0 +1,30 @@
+#ifndef TEST_IMP_H
+#define TEST_IMP_H
+
+#include "Utilities\Test\Test.h"
+
+#include <vector>
+
+class TestSimulation;
+class SimulationResults;
+class SimulationInfo;
+
+class TestImp : public Test
+{
+public:
+	void update();
+	void addSimulation(std::shared_ptr< TestSimulation> sim, std::shared_ptr< SimulationInfo> simInfo);
+
+	virtual void evaluate() = 0;
+	
+protected:
+	TestImp();
+	bool CheckAllSimulationRun();
+
+
+	std::vector< bool> simulationRun;
+	std::vector< std::shared_ptr< TestSimulation>> simulations;
+	std::vector< std::shared_ptr< SimulationResults>> simResults;
+	std::vector< std::shared_ptr< SimulationInfo>> simInfos;
+};
+#endif 
\ No newline at end of file
diff --git a/targets/tests/NumericalTests/Utilities/Test/package.include b/targets/tests/NumericalTests/Utilities/Test/package.include
new file mode 100644
index 000000000..e69de29bb
-- 
GitLab