Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicate topic name checking in Node #557

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ Node::Publisher Node::Advertise(const std::string &_topic,
auto currentTopics = this->AdvertisedTopics();

if (std::find(currentTopics.begin(), currentTopics.end(),
fullyQualifiedTopic) != currentTopics.end())
_topic) != currentTopics.end())
{
std::cerr << "Topic [" << topic << "] already advertised. You cannot"
<< " advertise the same topic twice on the same node."
Expand Down
8 changes: 5 additions & 3 deletions src/Node_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -951,10 +951,12 @@ TEST(NodeTest, AdvertiseTwoEqualTopics)

auto pub1 = node1.Advertise<msgs::Int32>(g_topic);
EXPECT_TRUE(pub1);
auto pub2 = node1.Advertise<msgs::StringMsg>(g_topic);
auto pub2 = node1.Advertise<msgs::Int32>(g_topic);
EXPECT_FALSE(pub2);
auto pub3 = node2.Advertise<msgs::StringMsg>(g_topic);
EXPECT_TRUE(pub3);
auto pub3 = node1.Advertise<msgs::StringMsg>(g_topic);
EXPECT_FALSE(pub3);
auto pub4 = node2.Advertise<msgs::StringMsg>(g_topic);
EXPECT_TRUE(pub4);
}

//////////////////////////////////////////////////
Expand Down
Loading