Skip to content

Commit

Permalink
fix checking topics
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 committed Nov 18, 2024
1 parent 0e1a222 commit 14c873f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
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

0 comments on commit 14c873f

Please sign in to comment.