Verifying that connection_header information is being populated now.
This commit is contained in:
parent
fc134acbbe
commit
fe4a5d18d3
|
@ -48,6 +48,12 @@ void string_handler(std::string name, // Topic name
|
|||
EXPECT_EQ(str->__getDataType(), msg_ptr->__getDataType());
|
||||
EXPECT_EQ(str->__getMessageDefinition(), msg_ptr->__getMessageDefinition());
|
||||
|
||||
EXPECT_EQ((*(str->__connection_header))["latching"], std::string("0"));
|
||||
EXPECT_EQ((*(str->__connection_header))["callerid"], std::string(""));
|
||||
EXPECT_EQ((*(str->__connection_header))["md5sum"], msg_ptr->__getMD5Sum());
|
||||
EXPECT_EQ((*(str->__connection_header))["type"], msg_ptr->__getDataType());
|
||||
EXPECT_EQ((*(str->__connection_header))["message_definition"], msg_ptr->__getMessageDefinition());
|
||||
|
||||
}
|
||||
|
||||
void any_handler(std::string name, // Topic name
|
||||
|
@ -62,6 +68,12 @@ void any_handler(std::string name, // Topic name
|
|||
EXPECT_EQ(any->__getDataType(), msg_ptr->__getDataType());
|
||||
EXPECT_EQ(any->__getMessageDefinition(), msg_ptr->__getMessageDefinition());
|
||||
|
||||
EXPECT_EQ((*(any->__connection_header))["latching"], std::string("0"));
|
||||
EXPECT_EQ((*(any->__connection_header))["callerid"], std::string(""));
|
||||
EXPECT_EQ((*(any->__connection_header))["md5sum"], msg_ptr->__getMD5Sum());
|
||||
EXPECT_EQ((*(any->__connection_header))["type"], msg_ptr->__getDataType());
|
||||
EXPECT_EQ((*(any->__connection_header))["message_definition"], msg_ptr->__getMessageDefinition());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -100,6 +112,7 @@ TEST(TestSuite, record_play_ref)
|
|||
|
||||
std_msgs::String msg;
|
||||
msg.data = std::string("jklmnop");
|
||||
|
||||
|
||||
EXPECT_TRUE(recorder.record("some_topic", msg, ros::Time::now()));
|
||||
|
||||
|
@ -121,6 +134,67 @@ TEST(TestSuite, record_play_ref)
|
|||
EXPECT_FALSE(player.nextMsg());
|
||||
}
|
||||
|
||||
void string_latching_handler(std::string name, // Topic name
|
||||
std_msgs::String* str, // Message pointer
|
||||
ros::Time t, // Message timestamp
|
||||
ros::Time t_shift, // Shifted time
|
||||
void* n) // Void pointer
|
||||
{
|
||||
std_msgs::String* msg_ptr = (std_msgs::String*)(n);
|
||||
|
||||
EXPECT_EQ((*(str->__connection_header))["latching"], std::string("1"));
|
||||
EXPECT_EQ((*(str->__connection_header))["callerid"], std::string("/my_node"));
|
||||
EXPECT_EQ((*(str->__connection_header))["md5sum"], msg_ptr->__getMD5Sum());
|
||||
EXPECT_EQ((*(str->__connection_header))["type"], msg_ptr->__getDataType());
|
||||
EXPECT_EQ((*(str->__connection_header))["message_definition"], msg_ptr->__getMessageDefinition());
|
||||
}
|
||||
|
||||
void any_latching_handler(std::string name, // Topic name
|
||||
ros::Message* any, // Message pointer
|
||||
ros::Time t, // Message timestamp
|
||||
ros::Time t_shift, // Shifted time
|
||||
void* n) // Void pointer
|
||||
{
|
||||
std_msgs::String* msg_ptr = (std_msgs::String*)(n);
|
||||
|
||||
EXPECT_EQ((*(any->__connection_header))["latching"], std::string("1"));
|
||||
EXPECT_EQ((*(any->__connection_header))["callerid"], std::string("/my_node"));
|
||||
EXPECT_EQ((*(any->__connection_header))["md5sum"], msg_ptr->__getMD5Sum());
|
||||
EXPECT_EQ((*(any->__connection_header))["type"], msg_ptr->__getDataType());
|
||||
EXPECT_EQ((*(any->__connection_header))["message_definition"], msg_ptr->__getMessageDefinition());
|
||||
}
|
||||
|
||||
TEST(TestSuite, record_play_latching)
|
||||
{
|
||||
ros::record::Recorder recorder;
|
||||
ASSERT_TRUE(recorder.open("test.bag"));
|
||||
|
||||
std_msgs::String msg;
|
||||
msg.data = std::string("qrestuv");
|
||||
msg.__connection_header = boost::shared_ptr<ros::M_string>(new ros::M_string);
|
||||
(*msg.__connection_header)["latching"] = std::string("1");
|
||||
(*msg.__connection_header)["callerid"] = std::string("/my_node");
|
||||
|
||||
EXPECT_TRUE(recorder.record("some_topic", msg, ros::Time::now()));
|
||||
|
||||
recorder.close();
|
||||
|
||||
ros::record::Player player;
|
||||
|
||||
ASSERT_TRUE(player.open(std::string("test.bag"), ros::Time()));
|
||||
|
||||
player.addHandler<std_msgs::String>(std::string("some_topic"),
|
||||
&string_latching_handler,
|
||||
&msg);
|
||||
player.addHandler<AnyMsg>(std::string("some_topic"),
|
||||
&any_latching_handler,
|
||||
&msg,
|
||||
false);
|
||||
|
||||
EXPECT_TRUE(player.nextMsg());
|
||||
EXPECT_FALSE(player.nextMsg());
|
||||
}
|
||||
|
||||
int main(int argc, char **argv){
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
|
Loading…
Reference in New Issue