123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- #include <gtest/gtest.h>
- #include <json.hpp>
- #include <Generator.h>
- //#define private public
- //cd cmake-build-debug/lib/test
- //gtb auslegung_test
- //catch throw
- //run
- using namespace mdd;
- TEST(ModuleMath, INT_PLUS_INT){
-
- auto generators = GetGenerators();
- IModule::Ptr mod = generators["mdd::ModuleMath"]->Generate();
- //mod->configure();
- mod->update();
- auto ids = mod->getOutputIDs();
- auto id = ids[0];
- auto output = mod->getOutput(id);
- auto res = output->getValue();
- EXPECT_FLOAT_EQ(res[0], 2.0);
- }
- /*
- TEST(ModuleMath, FLOAT_PLUS_FLOAT){
- IModule::Ptr test = GetGenerators()["class mdd::ModuleMath"]->Generate();
- test->configure();
- 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){
- ModuleMath test = ModuleMath(MathOperation::MULTIPLY);
- 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);
- }*/
|