19 #include <gtest/gtest.h> 21 #include <std_msgs/Bool.h> 23 #include <geometry_msgs/PoseStamped.h> 25 #include <variant_msgs/Test.h> 36 variant_msgs::Test m1;
38 m1.builtin_string =
"Test";
40 variant_msgs::Test::Ptr m3 = m2.
toMessage<variant_msgs::Test>();
42 EXPECT_EQ(ros::message_traits::datatype<variant_msgs::Test>(),
44 EXPECT_EQ(ros::message_traits::md5sum<variant_msgs::Test>(),
46 EXPECT_EQ(ros::message_traits::definition<variant_msgs::Test>(),
48 EXPECT_EQ(m1.builtin_int, m3->builtin_int);
49 EXPECT_EQ(m1.builtin_string, m3->builtin_string);
50 EXPECT_ANY_THROW(m2.
toMessage<std_msgs::Bool>());
52 geometry_msgs::PoseStamped m4;
54 EXPECT_EQ(ros::message_traits::datatype<geometry_msgs::PoseStamped>(),
56 EXPECT_EQ(ros::message_traits::md5sum<geometry_msgs::PoseStamped>(),
58 EXPECT_EQ(ros::message_traits::definition<geometry_msgs::PoseStamped>(),
67 variant_msgs::Test m1, m2;
69 m1.builtin_string =
"Test";
74 EXPECT_EQ(m1.builtin_int, v1[
"builtin_int"].
getValue<
int>());
75 EXPECT_EQ(m1.builtin_string, v1[
"builtin_string"].
getValue<std::string>());
78 EXPECT_EQ(ros::serialization::serializationLength<variant_msgs::Test>(m1),
80 EXPECT_NO_THROW(m2 = *m3.
toMessage<variant_msgs::Test>());
81 EXPECT_EQ(m1.builtin_int, m2.builtin_int);
82 EXPECT_EQ(m1.builtin_string, m2.builtin_string);
Header file providing the Message class interface.
Header file providing the MessageVariant class interface.
Header file providing the DataTypeRegistry class interface.
TEST(Message, Conversion)