30 #include <can_msgs/Frame.h> 34 #include <gtest/gtest.h> 51 TEST(TopicToSocketCANTest, checkCorrectData)
60 to_socketcan_bridge.setup();
63 driver_->init(
"string_not_used",
true);
66 ros::Publisher publisher_ = nh.advertise<can_msgs::Frame>(
"sent_messages", 10);
77 msg.is_extended =
true;
82 for (uint8_t i=0; i < msg.dlc; i++)
87 msg.header.frame_id =
"0";
97 can_msgs::Frame received;
101 EXPECT_EQ(received.id, msg.id);
102 EXPECT_EQ(received.dlc, msg.dlc);
103 EXPECT_EQ(received.is_extended, msg.is_extended);
104 EXPECT_EQ(received.is_rtr, msg.is_rtr);
105 EXPECT_EQ(received.is_error, msg.is_error);
106 EXPECT_EQ(received.data, msg.data);
109 TEST(TopicToSocketCANTest, checkInvalidFrameHandling)
124 to_socketcan_bridge.setup();
127 ros::Publisher publisher_ = nh.advertise<can_msgs::Frame>(
"sent_messages", 10);
138 msg.is_extended =
false;
140 msg.header.frame_id =
"0";
149 EXPECT_EQ(frame_collector_.frames.size(), 0);
151 msg.is_extended =
true;
157 EXPECT_EQ(frame_collector_.frames.size(), 1);
160 frame_collector_.frames.clear();
168 EXPECT_EQ(frame_collector_.frames.size(), 0);
171 int main(
int argc,
char **argv)
176 testing::InitGoogleTest(&argc, argv);
177 return RUN_ALL_TESTS();
void publish(const boost::shared_ptr< M > &message) const
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
std::list< can::Frame > frames
void frameCallback(const can::Frame &f)
TEST(TopicToSocketCANTest, checkCorrectData)
void convertSocketCANToMessage(const can::Frame &f, can_msgs::Frame &m)
ROSCPP_DECL void spinOnce()
int main(int argc, char **argv)