Skip to content

Commit

Permalink
Add more explicit test expectations
Browse files Browse the repository at this point in the history
* Expect CanonicalLink() == ModelByName("nested")->LinkByName("link2")
* Match up ModelByName and ModelByIndex expectations

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
  • Loading branch information
scpeters committed Aug 21, 2020
1 parent f5815f0 commit 6c7b3eb
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions test/integration/model_dom.cc
Original file line number Diff line number Diff line change
Expand Up @@ -342,30 +342,33 @@ TEST(DOMRoot, LoadNestedCanonicalLink)
EXPECT_EQ(0u, model->LinkCount());
EXPECT_EQ(nullptr, model->LinkByIndex(0));

EXPECT_TRUE(model->CanonicalLinkName().empty());

ASSERT_NE(nullptr, model->CanonicalLink());
// this reports the local name, not the nested name "nested::link2"
EXPECT_EQ("link2", model->CanonicalLink()->Name());

EXPECT_EQ(0u, model->JointCount());
EXPECT_EQ(nullptr, model->JointByIndex(0));

EXPECT_EQ(1u, model->FrameCount());
EXPECT_NE(nullptr, model->FrameByIndex(0));
EXPECT_EQ(nullptr, model->FrameByIndex(1));

EXPECT_EQ(2u, model->ModelCount());
EXPECT_TRUE(model->ModelNameExists("nested"));
EXPECT_TRUE(model->ModelNameExists("shallow"));
EXPECT_EQ(model->ModelByName("nested"), model->ModelByIndex(0));
EXPECT_EQ(model->ModelByName("shallow"), model->ModelByIndex(1));
EXPECT_EQ(nullptr, model->ModelByIndex(2));

// expect implicit canonical link
EXPECT_TRUE(model->CanonicalLinkName().empty());

// frame F is attached to __model__ and resolves to canonical link,
// which is "nested::link2"
std::string body;
EXPECT_TRUE(model->FrameByName("F")->ResolveAttachedToBody(body).empty());
EXPECT_EQ("nested::link2", body);

EXPECT_EQ(2u, model->ModelCount());
EXPECT_NE(nullptr, model->ModelByIndex(0));
EXPECT_NE(nullptr, model->ModelByIndex(1));
EXPECT_EQ(nullptr, model->ModelByIndex(2));

EXPECT_TRUE(model->ModelNameExists("nested"));
EXPECT_TRUE(model->ModelNameExists("shallow"));
EXPECT_EQ(model->ModelByName("nested")->LinkByName("link2"),
model->CanonicalLink());
// this reports the local name, not the nested name "nested::link2"
EXPECT_EQ("link2", model->CanonicalLink()->Name());

const sdf::Model *shallowModel = model->ModelByName("shallow");
EXPECT_EQ(1u, shallowModel->FrameCount());
Expand Down

0 comments on commit 6c7b3eb

Please sign in to comment.