Skip to content
Snippets Groups Projects
Commit 6499cddc authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add CFunctionEmbedderTable unit tests

parent b44f6fd4
No related branches found
No related tags found
1 merge request!37Feature/language
......@@ -37,6 +37,7 @@ add_executable (unit_tests
test_BinaryExpressionProcessor_logic.cpp
test_BiCGStab.cpp
test_CFunctionEmbedder.cpp
test_CFunctionEmbedderTable.cpp
test_ContinueProcessor.cpp
test_ConcatExpressionProcessor.cpp
test_CRSMatrix.cpp
......
#include <catch2/catch.hpp>
#include <CFunctionEmbedder.hpp>
#include <CFunctionEmbedderTable.hpp>
TEST_CASE("CFunctionEmbedderTable", "[language]")
{
rang::setControlMode(rang::control::Off);
CFunctionEmbedderTable table;
REQUIRE(table.size() == 0);
std::shared_ptr<ICFunctionEmbedder> embedded_sin = std::make_shared<CFunctionEmbedder<double, double>>(
std::function<double(double)>{[](double x) -> double { return std::sin(x); }});
table.add(embedded_sin);
REQUIRE(table.size() == 1);
std::shared_ptr<ICFunctionEmbedder> embedded_greater = std::make_shared<CFunctionEmbedder<bool, int, int>>(
std::function<bool(int, int)>{[](int i, int j) -> bool { return i > j; }});
table.add(embedded_greater);
REQUIRE(table.size() == 2);
REQUIRE(table[0] == embedded_sin);
REQUIRE(table[1] == embedded_greater);
#ifndef NDEBUG
REQUIRE_THROWS_AS(table[2], AssertError);
#endif // NDEBUG
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment