From a6f6b05f6da71a4dba3cc6fc7731c7307d7574e7 Mon Sep 17 00:00:00 2001
From: Stephane Del Pino <stephane.delpino44@gmail.com>
Date: Wed, 10 Jun 2020 16:16:06 +0200
Subject: [PATCH] Add CI tests for EmbeddedData

---
 tests/CMakeLists.txt        |  1 +
 tests/test_EmbeddedData.cpp | 31 +++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)
 create mode 100644 tests/test_EmbeddedData.cpp

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 65460257b..e695a79da 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 000000000..63ca0d427
--- /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");
+}
-- 
GitLab