Skip to content
Snippets Groups Projects
Commit f72c92d4 authored by Joan Solà Ortega's avatar Joan Solà Ortega
Browse files

Fix conditions for Capture::move()

parent b6c57ab0
No related branches found
No related tags found
1 merge request!403Resolve "Merge Aux/KeyFrames into Estimated Frames"
Pipeline #6222 passed
......@@ -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())
......
......@@ -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), "");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment