diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 65460257bf801ab56b0826c4f58db685ee5a0a95..e695a79daf8d6818e21c736c8fa3231fb19efcb6 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -53,6 +53,7 @@ add_executable (unit_tests test_CRSMatrix.cpp test_DataVariant.cpp test_DoWhileProcessor.cpp + test_EmbeddedData.cpp test_ExecutionPolicy.cpp test_FakeProcessor.cpp test_ForProcessor.cpp diff --git a/tests/test_EmbeddedData.cpp b/tests/test_EmbeddedData.cpp new file mode 100644 index 0000000000000000000000000000000000000000..63ca0d42705bed2cbe85e1697f32e443e20303e9 --- /dev/null +++ b/tests/test_EmbeddedData.cpp @@ -0,0 +1,31 @@ +#include <catch2/catch.hpp> + +#include <language/utils/DataHandler.hpp> +#include <language/utils/EmbeddedData.hpp> + +#include <sstream> + +// clazy:excludeall=non-pod-global-static + +TEST_CASE("EmbeddedData", "[language]") +{ + REQUIRE_NOTHROW(EmbeddedData{}); + EmbeddedData e; + { + EmbeddedData f{std::make_shared<DataHandler<double>>(std::make_shared<double>(1.3))}; + REQUIRE_NOTHROW(e = std::move(f)); + } + + REQUIRE(*dynamic_cast<const DataHandler<double>&>(e.get()).data_ptr() == 1.3); + + { + EmbeddedData f{std::make_shared<DataHandler<double>>(std::make_shared<double>(2.3))}; + REQUIRE_NOTHROW(e = f); + } + + REQUIRE(*dynamic_cast<const DataHandler<double>&>(e.get()).data_ptr() == 2.3); + + std::ostringstream fout; + fout << e; + REQUIRE(fout.str() == "embedded_data"); +}