From fd8b1285934afeabdc11f27f933c5bd16581e797 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Joan=20Sol=C3=A0?= <jsola@iri.upc.edu>
Date: Tue, 7 Apr 2020 00:13:16 +0200
Subject: [PATCH] Small documentation

---
 include/core/state_block/state_composite.h | 2 ++
 test/gtest_state_composite.cpp             | 9 +++++++++
 2 files changed, 11 insertions(+)

diff --git a/include/core/state_block/state_composite.h b/include/core/state_block/state_composite.h
index 76b476aa3..c7ffd98b4 100644
--- a/include/core/state_block/state_composite.h
+++ b/include/core/state_block/state_composite.h
@@ -44,6 +44,7 @@ class MatrixComposite
                                 const std::string &_col,
                                 const Eigen::MatrixXd &_mat_blk);
 
+        // throw error if queried block is not present
         bool            at(const std::string &_row,
                            const std::string &_col,
                            Eigen::MatrixXd &_mat_blk) const;
@@ -52,6 +53,7 @@ class MatrixComposite
         MatrixXd&       at(const std::string &_row,
                            const std::string &_col);
 
+        // return zero-size matrix if queried block is not present
         MatrixXd&       operator ()(const std::string &_row,
                                     const std::string &_col);
         const MatrixXd& operator ()(const std::string &_row,
diff --git a/test/gtest_state_composite.cpp b/test/gtest_state_composite.cpp
index 30c95a49b..38cfcfb60 100644
--- a/test/gtest_state_composite.cpp
+++ b/test/gtest_state_composite.cpp
@@ -176,6 +176,15 @@ TEST(MatrixComposite, productVector)
     ASSERT_MATRIX_APPROX(y.at("P"), yp, 1e-20);
     ASSERT_MATRIX_APPROX(y.at("O"), yo, 1e-20);
 
+    // throw if x has extra blocks
+    // x.emplace("V", Vector2d(3,3));
+    // ASSERT_DEATH(y = M * x , ""); // M * x --> does not die if x has extra blocks wrt M
+
+    // throw if x has missing blocks
+    // x.erase("O");
+    // cout << "x = " << x << endl;
+    // ASSERT_DEATH(y = M * x , ""); // M * x --> exception if x has missing blocks wrt M, not caught by ASSERT_DEATH
+
 }
 
 TEST(MatrixComposite, productMatrix)
-- 
GitLab