diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ed9f5564d2443b311ecc61b6380f4e4cde1d2830..04efe7836f098e31f42b5c93e5e9b1a74e4d9d4d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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 diff --git a/tests/test_CFunctionEmbedderTable.cpp b/tests/test_CFunctionEmbedderTable.cpp new file mode 100644 index 0000000000000000000000000000000000000000..28d15ce0e8a24a30d95cce58ee4ac42d229791b0 --- /dev/null +++ b/tests/test_CFunctionEmbedderTable.cpp @@ -0,0 +1,32 @@ +#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 +}