19 #include <gtest/gtest.h> 21 #include <variant_msgs/Test.h> 37 EXPECT_ANY_THROW(*p2);
41 boost::array<int, 3>* a1 =
new boost::array<int, 3>();
47 std::vector<int>* a2 =
new std::vector<int>(3);
62 EXPECT_EQ(a2, p3.getArray().get());
63 EXPECT_EQ(2, p3.getIndex());
68 variant_msgs::Test* m1 =
new variant_msgs::Test();
70 m1->builtin_string =
"Test";
73 offsetof(variant_msgs::Test, builtin_int));
75 p1.
getMessage(), offsetof(variant_msgs::Test, builtin_string));
78 EXPECT_EQ(offsetof(variant_msgs::Test, builtin_int), p1.
getOffset());
79 EXPECT_EQ(m1->builtin_int, *p1);
81 EXPECT_EQ(m1, p2.getMessage().get());
82 EXPECT_EQ(offsetof(variant_msgs::Test, builtin_string), p2.getOffset());
83 EXPECT_EQ(m1->builtin_string, *p2);
87 variant_msgs::Test* m1 =
new variant_msgs::Test();
88 m1->string_array[1].data =
"Test";
91 p1(m1, offsetof(variant_msgs::Test, string_array));
94 p3(p2, offsetof(std_msgs::String, data));
97 EXPECT_EQ(offsetof(variant_msgs::Test, string_array), p1.
getOffset());
103 EXPECT_EQ(offsetof(std_msgs::String, data), p3.
getOffset());
105 EXPECT_NO_THROW(p1.
reset());
106 EXPECT_ANY_THROW(*p1);
107 EXPECT_NO_THROW(*p2);
108 EXPECT_NO_THROW(*p3);
109 EXPECT_EQ(
"Test", *p3);
110 EXPECT_NO_THROW(p2.
reset());
111 EXPECT_ANY_THROW(*p2);
112 EXPECT_NO_THROW(*p3);
113 EXPECT_EQ(
"Test", *p3);
114 EXPECT_NO_THROW(p3.
reset());