From b02ccfdf7d4b8e6f6cfb719ea0897a697f77193a Mon Sep 17 00:00:00 2001 From: philbucher Date: Wed, 29 Jul 2020 12:09:49 +0200 Subject: [PATCH 1/2] exposing CopyCtor --- co_sim_io/python/info_to_python.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/co_sim_io/python/info_to_python.hpp b/co_sim_io/python/info_to_python.hpp index 2d116536..298d6b8b 100644 --- a/co_sim_io/python/info_to_python.hpp +++ b/co_sim_io/python/info_to_python.hpp @@ -43,6 +43,7 @@ void AddCoSimIOInfoToPython(pybind11::module& m) auto py_info = py::class_(m,"Info") .def(py::init<>()) + .def(py::init()) .def("Has", &CoSimIO::Info::Has) .def("Erase", &CoSimIO::Info::Erase) .def("Clear", &CoSimIO::Info::Clear) From 22bc4e33dc3b09fbe9d39c0902c0265e15eb0bc6 Mon Sep 17 00:00:00 2001 From: philbucher Date: Wed, 29 Jul 2020 12:09:58 +0200 Subject: [PATCH 2/2] adding test --- tests/co_sim_io/python/test_info.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/co_sim_io/python/test_info.py b/tests/co_sim_io/python/test_info.py index 9fcb116f..e91d08b8 100644 --- a/tests/co_sim_io/python/test_info.py +++ b/tests/co_sim_io/python/test_info.py @@ -228,6 +228,27 @@ def test_print(self): self.assertMultiLineEqual(str(info), exp_string) + def test_copy_constructor(self): + info = CoSimIO.Info() + + info.SetString("keyword", "awesome") + info.SetBool("is_converged", True) + info.SetString("identifier", "mesh") + info.SetDouble("tol", 0.008) + info.SetInt("echo_level", 2) + info.SetInt("checking", 22) + + copied_info = CoSimIO.Info(info) + + self.assertEqual(copied_info.Size(), 6) + + self.assertEqual(copied_info.GetString("keyword"), "awesome") + self.assertTrue(copied_info.GetBool("is_converged")) + self.assertEqual(copied_info.GetString("identifier"), "mesh") + self.assertAlmostEqual(copied_info.GetDouble("tol"), 0.008) + self.assertEqual(copied_info.GetInt("echo_level"), 2) + self.assertEqual(copied_info.GetInt("checking"), 22) + if __name__ == '__main__': unittest.main()