#include <gtest/gtest.h>
#include <json.hpp>
//#define private public
#include <ModuleMath.h>

//cd cmake-build-debug/lib/test
//gtb auslegung_test
//catch throw
//run


using namespace mdd;
TEST(ModuleMath, INT_PLUS_INT){
    ModuleMath test = ModuleMath();
    test.update();

    EXPECT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue()["value"].get<int>(), 2);
}

TEST(ModuleMath, FLOAT_PLUS_FLOAT){
    ModuleMath test = ModuleMath();
    test.getInput(test.getInputIDs()[0])->setDefaultValue()["value"] = 1.25;
    test.getInput(test.getInputIDs()[1])->setDefaultValue()["value"] = 3.125;
    test.update();

    EXPECT_FLOAT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue()["value"], 4.375);
}

TEST(ModuleMath, FLOAT_PLUS_FLOAT_HARDER){
    ModuleMath test = ModuleMath();
    test.getInput(test.getInputIDs()[0])->setDefaultValue()["value"] = 2.2;
    test.getInput(test.getInputIDs()[1])->setDefaultValue()["value"] = -3.4;
    test.update();

    EXPECT_FLOAT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue()["value"], -1.2);
}

TEST(ModuleMath, ARRAY_PLUS_ARRAY){
    ModuleMath test = ModuleMath();
    test.getInput(test.getInputIDs()[0])->setDefaultValue()["value"] = {1,2.5,3.75,45};
    test.getInput(test.getInputIDs()[1])->setDefaultValue()["value"] = {10,31,23,23};
    test.update();

    EXPECT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue()["value"].dump(), "[11,33.5,26.75,68]");
}

TEST(ModuleMath, INT_PLUS_ARRAY){
    ModuleMath test = ModuleMath();
    test.getInput(test.getInputIDs()[0])->setDefaultValue()["value"] = 2.5;
    test.getInput(test.getInputIDs()[1])->setDefaultValue()["value"] = {10,31,23,23};
    test.update();

    EXPECT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue()["value"].dump(), "[12.5,33.5,25.5,25.5]");
}

TEST(ModuleMath, ARRAY_PLUS_INT){
    ModuleMath test = ModuleMath();
    test.getInput(test.getInputIDs()[0])->setDefaultValue()["value"] = {10,31,23,23};
    test.getInput(test.getInputIDs()[1])->setDefaultValue()["value"] = 2.5;
    test.update();

    EXPECT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue()["value"].dump(), "[12.5,33.5,25.5,25.5]");
}

TEST(ModuleMath, ARRAY_MINUS_ARRAY){
    ModuleMath test = ModuleMath(SUBTRACT);
    test.getInput(test.getInputIDs()[0])->setDefaultValue()["value"] = {10,31,3,45};
    test.getInput(test.getInputIDs()[1])->setDefaultValue()["value"] = {1,2.5,23,23};
    test.update();

    EXPECT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue()["value"].dump(), "[9,28.5,-20,22]");
}

TEST(ModuleMath, ARRAY_MAL_ARRAY){
    ModuleMath test = ModuleMath(MULTIPLY);
    test.getInput(test.getInputIDs()[0])->setDefaultValue()["value"] = {10,30,-3.5,45};
    test.getInput(test.getInputIDs()[1])->setDefaultValue()["value"] = {1,2.5,2.25,20};
    test.update();

    EXPECT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue()["value"].dump(), "[10,75.0,-7.875,900]");
}

TEST(ModuleMath, ARRAY_DURCH_ARRAY){
    ModuleMath test = ModuleMath(DIVIDE);
    test.getInput(test.getInputIDs()[0])->setDefaultValue()["value"] = {10,30,-3.5,45};
    test.getInput(test.getInputIDs()[1])->setDefaultValue()["value"] = {4,2.5,2,20};
    test.update();

    EXPECT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue()["value"].dump(), "[2.5,12.0,-1.75,2.25]");
}