Skip to content

Commit

Permalink
Merge pull request #564 from dartsim/fix_554
Browse files Browse the repository at this point in the history
Fix 554
  • Loading branch information
jslee02 committed Dec 13, 2015
2 parents b333113 + e9661e9 commit 77cb772
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dart/common/detail/NameManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ template <class T>
void NameManager<T>::removeEntries(const std::string& _name, const T& _obj)
{
removeObject(_obj);
removeName(_name, false);
removeName(_name);
}

//==============================================================================
Expand Down
30 changes: 30 additions & 0 deletions unittests/testNameManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,36 @@ TEST(NameManagement, SetPattern)
EXPECT_TRUE( test_mgr.getObject("(2)-Entity") == entity2 );
}

//==============================================================================
TEST(NameManagement, Regression554)
{
dart::common::NameManager< std::shared_ptr<int> > test_mgr("test", "name");

std::shared_ptr<int> int0(new int(0));
std::shared_ptr<int> int1(new int(1));
std::shared_ptr<int> int2(new int(2));
std::shared_ptr<int> int_another0(new int(0));

test_mgr.issueNewNameAndAdd(std::to_string(*int0), int0);
test_mgr.issueNewNameAndAdd(std::to_string(*int1), int1);
test_mgr.issueNewNameAndAdd(std::to_string(*int2), int2);

EXPECT_TRUE( test_mgr.getObject("0") == int0 );
EXPECT_TRUE( test_mgr.getObject("1") == int1 );
EXPECT_TRUE( test_mgr.getObject("2") == int2 );

bool res1 = test_mgr.addName(std::to_string(*int_another0), int_another0);
EXPECT_FALSE( res1 );

test_mgr.removeEntries(std::to_string(*int_another0), int_another0);
bool res2 = test_mgr.addName(std::to_string(*int_another0), int_another0);
EXPECT_TRUE( res2 );

EXPECT_TRUE( test_mgr.getObject("0") == int_another0 );
EXPECT_TRUE( test_mgr.getObject("1") == int1 );
EXPECT_TRUE( test_mgr.getObject("2") == int2 );
}

//==============================================================================
TEST(NameManagement, WorldSkeletons)
{
Expand Down

0 comments on commit 77cb772

Please sign in to comment.