Skip to content
Snippets Groups Projects
Commit 3889a8c4 authored by Christoph Lehmann's avatar Christoph Lehmann
Browse files

[T] Added unit tests for model eval oder check

parent 55399d30
No related branches found
No related tags found
No related merge requests found
...@@ -88,6 +88,7 @@ ogs_add_executable(testrunner ${TEST_SOURCES}) ...@@ -88,6 +88,7 @@ ogs_add_executable(testrunner ${TEST_SOURCES})
target_sources( target_sources(
testrunner PRIVATE ProcessLib/Graph/TestGet.cpp testrunner PRIVATE ProcessLib/Graph/TestGet.cpp
ProcessLib/Graph/TestApply.cpp ProcessLib/Graph/TestApply.cpp
ProcessLib/Graph/TestCheckEvalOrderRT.cpp
) )
target_link_libraries( target_link_libraries(
......
/**
* \file
* \copyright
* Copyright (c) 2012-2024, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#include <gtest/gtest.h>
#include "ProcessLib/Graph/CheckEvalOrderRT.h"
namespace TestCheckEvalOrderRT
{
struct NoOp
{
void eval();
};
struct OutD
{
void eval(double&) {}
};
struct InD
{
void eval(double const&) {}
};
struct InSOutD
{
void eval(double&, std::string const&) {}
};
struct OutCD
{
void eval(double&, char&) {}
};
struct InCSOutIU
{
void eval(char const&, unsigned&, std::string const&, int&);
};
struct InIU
{
void eval(unsigned const&, int const&);
};
} // namespace TestCheckEvalOrderRT
TEST(ProcessLib_Graph_CheckEvalOrderRT, Success)
{
using namespace TestCheckEvalOrderRT;
{
using Models = std::tuple<NoOp>;
using Inputs = std::tuple<>;
ASSERT_TRUE(
(ProcessLib::Graph::isEvalOrderCorrectRT<Models, Inputs>()));
}
{
using Models = std::tuple<OutD>;
using Inputs = std::tuple<>;
ASSERT_TRUE(
(ProcessLib::Graph::isEvalOrderCorrectRT<Models, Inputs>()));
}
{
using Models = std::tuple<InD>;
using Inputs = std::tuple<double>;
ASSERT_TRUE(
(ProcessLib::Graph::isEvalOrderCorrectRT<Models, Inputs>()));
}
{
using Models = std::tuple<OutD, InD>;
using Inputs = std::tuple<>;
ASSERT_TRUE(
(ProcessLib::Graph::isEvalOrderCorrectRT<Models, Inputs>()));
}
{
using Models = std::tuple<InSOutD, NoOp, InD>;
using Inputs = std::tuple<std::string>;
ASSERT_TRUE(
(ProcessLib::Graph::isEvalOrderCorrectRT<Models, Inputs>()));
}
{
using Models = std::tuple<OutCD, NoOp, InCSOutIU, InD, InIU>;
using Inputs = std::tuple<std::string>;
ASSERT_TRUE(
(ProcessLib::Graph::isEvalOrderCorrectRT<Models, Inputs>()));
}
{
using Models = std::tuple<NoOp, OutCD, InD, InCSOutIU, InIU>;
using Inputs = std::tuple<std::string>;
ASSERT_TRUE(
(ProcessLib::Graph::isEvalOrderCorrectRT<Models, Inputs>()));
}
}
TEST(ProcessLib_Graph_CheckEvalOrderRT, Fail)
{
using namespace TestCheckEvalOrderRT;
{
using Models = std::tuple<InD>;
using Inputs = std::tuple<>;
ASSERT_FALSE(
(ProcessLib::Graph::isEvalOrderCorrectRT<Models, Inputs>()))
<< "Expected to fail since the required double value is not "
"provided as an input.";
}
{
using Models = std::tuple<InD, OutD>;
using Inputs = std::tuple<>;
ASSERT_FALSE(
(ProcessLib::Graph::isEvalOrderCorrectRT<Models, Inputs>()))
<< "Expected to fail: double value is consumed before being "
"computed.";
}
{
using Models = std::tuple<NoOp, InSOutD, OutD, InD>;
using Inputs = std::tuple<std::string>;
ASSERT_FALSE(
(ProcessLib::Graph::isEvalOrderCorrectRT<Models, Inputs>()))
<< "Expected to fail: double value has two producers.";
}
{
using Models = std::tuple<OutCD, InIU, NoOp, InCSOutIU, InD>;
using Inputs = std::tuple<std::string>;
ASSERT_FALSE(
(ProcessLib::Graph::isEvalOrderCorrectRT<Models, Inputs>()))
<< "Expected to fail: wrong evaluation order.";
}
{
using Models = std::tuple<NoOp, OutCD, InD, OutD, InCSOutIU, InIU>;
using Inputs = std::tuple<std::string>;
ASSERT_FALSE(
(ProcessLib::Graph::isEvalOrderCorrectRT<Models, Inputs>()))
<< "Expected to fail: double value has two producers.";
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment