From 32515e72e7ca25de98f85854bd934d02f66b467e Mon Sep 17 00:00:00 2001
From: Joris Vaillant <joris.vaillant@navya.tech>
Date: Wed, 25 Oct 2023 10:06:44 +0200
Subject: [PATCH] core: Fix std_vector unit tests

---
 unittest/python/test_std_vector.py | 16 ++++++++++------
 unittest/std_vector.cpp            |  5 +++--
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/unittest/python/test_std_vector.py b/unittest/python/test_std_vector.py
index 532b7df..b34a32c 100644
--- a/unittest/python/test_std_vector.py
+++ b/unittest/python/test_std_vector.py
@@ -85,11 +85,15 @@ print("-----------------")
 # pprint.pprint(list(l4))
 # checkZero(l4)
 
-# TODO fail
-l5_copy = std_vector.StdVec_Mat2d(l5)
+# Test StdVec_Mat2d that had been registered
+# before calling exposeStdVectorEigenSpecificType
 
-# test l5 == l5_copy == l5_py
+# Test conversion and tolistl5 == l5_copy == l5_py
+l5_copy = std_vector.StdVec_Mat2d(l5)
 l5_py = l5_copy.tolist()
-# Test l5[0] is zero
-l5[0].setZero()
-# TODO test
+checkAllValues(l5, l5_copy)
+checkAllValues(l5, l5_py)
+
+# Test mutable __getitem__
+l5[0][:] = 0.0
+assert np.allclose(l5[0], 0.0)
diff --git a/unittest/std_vector.cpp b/unittest/std_vector.cpp
index 225eae1..942d4ae 100644
--- a/unittest/std_vector.cpp
+++ b/unittest/std_vector.cpp
@@ -52,9 +52,10 @@ BOOST_PYTHON_MODULE(std_vector) {
 
   // Test matrix modification
   // Mat2d don't have tolist, reserve, mutable __getitem__ and from list
-  // conversion exposeStdVectorEigenSpecificType must add those methods to Mat2d
+  // conversion
+  // exposeStdVectorEigenSpecificType must add those methods to StdVec_Mat2d
   bp::class_<std::vector<Eigen::Matrix2d> >("StdVec_Mat2d")
       .def(boost::python::vector_indexing_suite<
            std::vector<Eigen::Matrix2d> >());
-  exposeStdVectorEigenSpecificType<Eigen::Matrix3d>("Mat2d");
+  exposeStdVectorEigenSpecificType<Eigen::Matrix2d>("Mat2d");
 }
-- 
GitLab