diff --git a/src/capture/capture_base.cpp b/src/capture/capture_base.cpp index 03bc1c480729e7d7ffe730a6a5e090f936c66b2b..957ed68d0dff047513fb84d9d2f1781b7599b36c 100644 --- a/src/capture/capture_base.cpp +++ b/src/capture/capture_base.cpp @@ -177,11 +177,9 @@ void CaptureBase::unfix() void CaptureBase::move(FrameBasePtr _frm_ptr) { - WOLF_WARN_COND(this->getFrame() == nullptr, "moving a capture not linked to any frame. Consider just linking it with link() instead of move()!"); + WOLF_WARN_COND(this->getFrame() == nullptr, "Moving Capture ", id(), " at ts=", getTimeStamp(), " not linked to any frame. Consider just linking it with link() instead of move()!"); - assert((this->getFrame() == nullptr || not this->getFrame()->getProblem()) && "Forbidden: moving a capture already linked to a KF"); - assert((_frm_ptr != nullptr) && "Forbidden: moving a capture to a null frame"); - assert((_frm_ptr != nullptr && _frm_ptr->getProblem()) && "Forbidden: moving a capture to a non-estimated frame"); + assert((this->getFrame() == nullptr || not this->getFrame()->getProblem()) && "Forbidden: trying to move a capture already linked to a KF!"); // Unlink if (this->getFrame()) diff --git a/test/gtest_capture_base.cpp b/test/gtest_capture_base.cpp index d114c7441f0603c5b803636b442c3448c05cb9ab..3a0cbc4555c88bd40f0a656e2a73ff2a619654b6 100644 --- a/test/gtest_capture_base.cpp +++ b/test/gtest_capture_base.cpp @@ -119,6 +119,7 @@ TEST(CaptureBase, move_from_F_to_KF) ASSERT_EQ(KF->getCaptureList().size(), 2); ASSERT_EQ(F->getCaptureList().size(), 0); + ASSERT_TRUE(C->getProblem()); } TEST(CaptureBase, move_from_F_to_null) @@ -133,7 +134,10 @@ TEST(CaptureBase, move_from_F_to_null) ASSERT_EQ(F->getCaptureList().size(), 1); - ASSERT_DEATH( C->move(F0), ""); + C->move(F0); + + ASSERT_EQ(F->getCaptureList().size(), 0); + ASSERT_FALSE(C->getProblem()); } TEST(CaptureBase, move_from_null_to_KF) @@ -151,6 +155,7 @@ TEST(CaptureBase, move_from_null_to_KF) C->move(KF); ASSERT_EQ(KF->getCaptureList().size(), 2); + ASSERT_TRUE(C->getProblem()); } TEST(CaptureBase, move_from_null_to_F) @@ -161,6 +166,23 @@ TEST(CaptureBase, move_from_null_to_F) auto C = std::make_shared<CaptureBase>("Dummy", 0.0); + C->move(F); + + ASSERT_EQ(F->getCaptureList().size(), 1); + + ASSERT_FALSE(C->getProblem()); +} + +TEST(CaptureBase, move_from_KF_to_F) +{ + ProblemPtr problem = Problem::create("PO", 2); + + auto KF = problem->emplaceFrame(0.0); // dummy F object + + auto F = std::make_shared<FrameBase>(0.0, nullptr); // dummy F object + + auto C = CaptureBase::emplace<CaptureBase>(KF, "Dummy", 0.0); + ASSERT_DEATH(C->move(F), ""); }