From 1d1ced2feced4103114821c2effadbf63d46e880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Sol=C3=A0?= <jsola@iri.upc.edu> Date: Wed, 25 Mar 2020 22:07:16 +0100 Subject: [PATCH] Improve tests --- src/frame/frame_base.cpp | 2 +- test/gtest_has_state_blocks.cpp | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/frame/frame_base.cpp b/src/frame/frame_base.cpp index 37d710952..db17da699 100644 --- a/src/frame/frame_base.cpp +++ b/src/frame/frame_base.cpp @@ -321,7 +321,7 @@ void FrameBase::setProblem(ProblemPtr _problem) NodeBase::setProblem(_problem); if (this->isKey()) - registerNewStateBlocks(getProblem()); + registerNewStateBlocks(_problem); for (auto cap : capture_list_) cap->setProblem(_problem); diff --git a/test/gtest_has_state_blocks.cpp b/test/gtest_has_state_blocks.cpp index 4118f0f4d..d8b46e9b7 100644 --- a/test/gtest_has_state_blocks.cpp +++ b/test/gtest_has_state_blocks.cpp @@ -50,7 +50,7 @@ class HasStateBlocksTest : public testing::Test }; -TEST_F(HasStateBlocksTest, Notifications_setKey) +TEST_F(HasStateBlocksTest, Notifications_setKey_add) { Notification n; ASSERT_FALSE(problem->getStateBlockNotification(sbp0, n)); @@ -65,7 +65,7 @@ TEST_F(HasStateBlocksTest, Notifications_setKey) ASSERT_EQ(n, ADD); } -TEST_F(HasStateBlocksTest, Notifications_addStateBlock) +TEST_F(HasStateBlocksTest, Notifications_add_makeKF) { Notification n; @@ -91,15 +91,24 @@ TEST_F(HasStateBlocksTest, Notifications_addStateBlock) ASSERT_TRUE(problem->getStateBlockNotification(sbv0, n)); ASSERT_EQ(n, ADD); +} + +TEST_F(HasStateBlocksTest, Notifications_makeKF_add) +{ + Notification n; + // first make KF, then add SB F1->link(problem->getTrajectory()); + F1->setKey(); F1->addStateBlock("P", sbp1); - F1->setKey(); - ASSERT_TRUE(problem->getStateBlockNotification(sbp1, n)); + ASSERT_EQ(n, ADD); + + // add another SB + ASSERT_FALSE(problem->getStateBlockNotification(sbv1, n)); F1->addStateBlock("V", sbv1); -- GitLab