diff --git a/include/core/state_block/state_composite.h b/include/core/state_block/state_composite.h index 76b476aa33daebd713c447de5be17102c4f6e608..c7ffd98b448b625884cc4feb6e02f53e6ab0b4df 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 30c95a49b2782d6923f538d8f14b43a6bf73ef68..38cfcfb603dc70a9e27ae644a8e7b31430d53957 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)