123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- #include <gtest/gtest.h>
- #include <json.hpp>
- //#include <Generator.h>
- #include <Registration.h>
- //#define private public
- //cd cmake-build-debug/lib/test
- //gtb auslegung_test
- //catch throw
- //run
- using namespace mdd;
- auto regi = Registration();
- TEST(ModuleMath, Create) {
- IModule::Ptr mod = regi.generateModule("ModuleMath");
- auto input = mod->getInput(0);
- EXPECT_FLOAT_EQ(input->getValue()[0], 1.0);
- input = mod->getInput(1);
- EXPECT_FLOAT_EQ(input->getValue()[0], 1.0);
- auto output = mod->getOutput(0);
- EXPECT_FLOAT_EQ(output->getValue()[0], 1.0);
- int i = 0;
- }
- TEST(ModuleMath, INT_PLUS_INT){
- IModule::Ptr mod = regi.generateModule("ModuleMath");
- auto config = mod->getBaseConfiguration();
- mod->configure(config);
- mod->update();
- auto output = mod->getOutput(0);
- auto res = output->getValue();
- EXPECT_FLOAT_EQ(res[0], 2.0);
- }
- /*
- TEST(ModuleMath, FLOAT_PLUS_FLOAT){
- IModule::Ptr test = GetGenerators()["mdd::ModuleMath"]->Generate();
- test->configure(test->getBaseConfiguration());
- test->getInput(test->getInputIDs()[0])->setValue() = { 1.25 };
- test->getInput(test->getInputIDs()[1])->setValue() = { 3.125 };
- test->update();
- EXPECT_FLOAT_EQ(test->getOutput(test->getOutputIDs()[0])->getValue()[0], 4.375);
- }
- //*/
- /*
- TEST(ModuleMath, FLOAT_PLUS_FLOAT_HARDER){
- ModuleMath test = ModuleMath();
- test.getInput(test.getInputIDs()[0])->setValue() = { 2.2 };
- test.getInput(test.getInputIDs()[1])->setValue() = { -3.4 };
- test.update();
- EXPECT_FLOAT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue()[0], -1.2);
- }
- TEST(ModuleMath, ARRAY_PLUS_ARRAY) {
- ModuleMath test = ModuleMath();
- test.getInput(test.getInputIDs()[0])->setValue() = { 1,2.5,3.75,45 };
- test.getInput(test.getInputIDs()[1])->setValue() = { 10,31,23,23 };
- std::vector<double> expect = { 11, 33.5, 26.75, 68 };
- test.update();
- EXPECT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue(), expect);
- }
- TEST(ModuleMath, INT_PLUS_ARRAY){
- ModuleMath test = ModuleMath();
- test.getInput(test.getInputIDs()[0])->setValue() = { 2.5 };
- test.getInput(test.getInputIDs()[1])->setValue() = {10,31,23,23};
- std::vector<double> expect = { 12.5,33.5,25.5,25.5 };
- test.update();
- EXPECT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue(), expect);
- }
- TEST(ModuleMath, ARRAY_PLUS_INT){
- ModuleMath test = ModuleMath();
- test.getInput(test.getInputIDs()[0])->setValue() = {10,31,23,23};
- test.getInput(test.getInputIDs()[1])->setValue() = { 2.5 };
- std::vector<double> expect = { 12.5,33.5,25.5,25.5 };
- test.update();
- EXPECT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue(), expect);
- }
- TEST(ModuleMath, ARRAY_MINUS_ARRAY){
- ModuleMath test = ModuleMath(MathOperation::SUBTRACT);
- test.getInput(test.getInputIDs()[0])->setValue() = {10,31,3,45};
- test.getInput(test.getInputIDs()[1])->setValue() = {1,2.5,23,23};
- std::vector<double> expect = { 9,28.5,-20,22 };
- test.update();
- EXPECT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue(), expect);
- }
- */
- /*
- TEST(ModuleMath, ARRAY_MAL_ARRAY){
- IModule::Ptr test = GetGenerators()["mdd::ModuleMath"]->Generate();
- test->configure(R"JSON(
- {
- "operation": "multiply"
- }
- )JSON");
- test->update();
- test->getInput(test->getInputIDs()[0])->setValue() = {10,30,-3.5,45};
- test->getInput(test->getInputIDs()[1])->setValue() = {1,2.5,2.25,20};
- std::vector<double> expect = { 10,75.0,-7.875,900 };
- test->update();
- EXPECT_EQ(test->getOutput(test->getOutputIDs()[0])->getValue(), expect);
- }
- //*/
- /*
- TEST(ModuleMath, ARRAY_DURCH_ARRAY){
- ModuleMath test = ModuleMath(MathOperation::DIVIDE);
- test.getInput(test.getInputIDs()[0])->setValue() = {10,30,-3.5,45};
- test.getInput(test.getInputIDs()[1])->setValue() = {4,2.5,2,20};
- std::vector<double> expect = { 2.5,12.0,-1.75,2.25 };
- test.update();
- EXPECT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue(), expect);
- }*/
|