Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fredroy committed Nov 5, 2024
1 parent 6f256ec commit cb5dbbe
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sofa/framework/Core/src/sofa/core/objectmodel/BaseData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ bool BaseData::setParent(BaseData* parent, const std::string& path)
m_counter++;
}
// the referenced parent data has not been created yet but a path has been given
else if (!path.empty())
else if (!path.empty())
{
parentData.setPath(path);
}
Expand Down
42 changes: 42 additions & 0 deletions Sofa/framework/SimpleApi/test/SimpleApi_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,45 @@ TEST_F(SimpleApi_test, createParamString )
{
ASSERT_TRUE( testParamString() );
}

TEST(SimpleApi_test_solo, testIsSetWithDataLink)
{
const Simulation::SPtr simu = createSimulation("DAG");
const Node::SPtr root = createRootNode(simu, "root");

// test not set
const auto obj1 = createObject(root, "DefaultAnimationLoop", {
{"name", "loop1"}
});
auto* objdata1 = obj1->findData("printLog");
ASSERT_FALSE(objdata1->isSet());

// test set
const auto obj2 = createObject(root, "DefaultAnimationLoop", {
{"name", "loop2"},
{"printLog", "false"}
});
auto* objdata2 = obj2->findData("printLog");
ASSERT_TRUE(objdata2->isSet());

// test set through a link of a already created object
const auto obj3 = createObject(root, "DefaultAnimationLoop", {
{"name", "loop3"},
{"printLog", "@/loop2.printLog"}
});
auto* objdata3 = obj3->findData("printLog");
ASSERT_TRUE(objdata3->isSet());

// test set through a link of a not yet created object (deferred linking)
const auto obj4 = createObject(root, "DefaultAnimationLoop", {
{"name", "loop4"},
{"printLog", "@/loop5.printLog"}
});
const auto obj5 = createObject(root, "DefaultAnimationLoop", {
{"name", "loop5"},
{"printLog", "true"}
});
auto* objdata4 = obj4->findData("printLog");
ASSERT_TRUE(objdata4->isSet());

}

0 comments on commit cb5dbbe

Please sign in to comment.