5 #include <gtest/gtest.h> 9 #include <can_msgs/Frame.h> 10 #include <std_msgs/Bool.h> 11 #include <std_msgs/Int8.h> 12 #include <std_msgs/Int16.h> 13 #include <std_msgs/Int32.h> 14 #include <std_msgs/Int64.h> 15 #include <std_msgs/UInt8.h> 16 #include <std_msgs/UInt16.h> 17 #include <std_msgs/UInt32.h> 18 #include <std_msgs/UInt64.h> 26 #include "../src/DbcIterator.hpp" 35 template <
typename MsgT>
115 typedef std_msgs::Int8 Msg1;
116 typedef std_msgs::Int8 Msg2;
117 typedef std_msgs::Int8 Msg3;
118 typedef std_msgs::Bool Msg4;
144 msg.is_error =
false;
145 msg.is_extended =
false;
147 msg.data = {23, 43, 53, 1, 0, 0, 0, 0};
167 EXPECT_EQ(rx0.
getLatest().header.stamp, msg.header.stamp);
168 EXPECT_EQ(rx0.
getLatest().data, msg.data);
171 EXPECT_EQ(rx3.
getLatest().data, 53 + 18);
179 typedef std_msgs::Int8 Msg1;
180 typedef std_msgs::UInt8 Msg2;
181 typedef std_msgs::Int16 Msg3;
182 typedef std_msgs::UInt16 Msg4;
208 msg.is_error =
false;
209 msg.is_extended =
false;
211 msg.data = {11, 22, 0xEF, 0xCD, 0xAB, 0x89, 0, 0};
231 EXPECT_EQ(rx0.
getLatest().header.stamp, msg.header.stamp);
232 EXPECT_EQ(rx0.
getLatest().data, msg.data);
233 EXPECT_EQ(rx1.
getLatest().data, (Msg1::_data_type)11);
234 EXPECT_EQ(rx2.
getLatest().data, (Msg2::_data_type)22);
235 EXPECT_EQ(rx3.
getLatest().data, (Msg3::_data_type)0xCDEF);
236 EXPECT_EQ(rx4.
getLatest().data, (Msg4::_data_type)0x89AB);
243 typedef std_msgs::Int32 Msg1;
244 typedef std_msgs::UInt32 Msg2;
264 msg.is_error =
false;
265 msg.is_extended =
false;
267 msg.data = {0xEF, 0xCD, 0xAB, 0x89, 0x67, 0x45, 0x23, 0x01};
283 EXPECT_EQ(rx0.
getLatest().header.stamp, msg.header.stamp);
284 EXPECT_EQ(rx0.
getLatest().data, msg.data);
285 EXPECT_EQ(rx1.
getLatest().data, (Msg1::_data_type)0x89ABCDEF);
286 EXPECT_EQ(rx2.
getLatest().data, (Msg2::_data_type)0x01234567);
293 typedef std_msgs::Int64 Msg1;
310 msg.is_error =
false;
311 msg.is_extended =
false;
313 msg.data = {0xE0, 0xCD, 0xAB, 0x89, 0x67, 0x45, 0x23, 0x01};
327 EXPECT_EQ(rx0.
getLatest().header.stamp, msg.header.stamp);
328 EXPECT_EQ(rx0.
getLatest().data, msg.data);
329 EXPECT_EQ(rx1.
getLatest().data, (Msg1::_data_type)0x0123456789ABCDE0);
337 typedef std_msgs::UInt64 Msg1;
354 msg.is_error =
false;
355 msg.is_extended =
false;
357 msg.data = {0xE0, 0xCD, 0xAB, 0x89, 0x67, 0x45, 0x23, 0x01};
371 EXPECT_EQ(rx0.
getLatest().header.stamp, msg.header.stamp);
372 EXPECT_EQ(rx0.
getLatest().data, msg.data);
373 EXPECT_EQ(rx1.
getLatest().data, (Msg1::_data_type)0x0123456789ABCDE0);
381 typedef std_msgs::Int32 Msg1;
382 typedef std_msgs::Int32 Msg2;
402 msg.is_error =
false;
403 msg.is_extended =
false;
405 msg.data = {210, 0, 0, 0, 0, 0, 0, 153};
421 EXPECT_EQ(rx0.
getLatest().header.stamp, msg.header.stamp);
422 EXPECT_EQ(rx0.
getLatest().data, msg.data);
432 typedef std_msgs::Int64 Msg1;
449 msg.is_error =
false;
450 msg.is_extended =
false;
452 msg.data = {210, 0, 0, 0, 0, 0, 0, 0};
466 EXPECT_EQ(rx0.
getLatest().header.stamp, msg.header.stamp);
467 EXPECT_EQ(rx0.
getLatest().data, msg.data);
476 typedef std_msgs::Int64 Msg1;
493 msg.is_error =
false;
494 msg.is_extended =
false;
496 msg.data = {0, 0, 0, 0, 0, 0, 0, 210};
510 EXPECT_EQ(rx0.
getLatest().header.stamp, msg.header.stamp);
511 EXPECT_EQ(rx0.
getLatest().data, msg.data);
520 typedef std_msgs::Int16 Msg1;
521 typedef std_msgs::UInt16 Msg2;
522 typedef std_msgs::Int16 Msg3;
523 typedef std_msgs::Int16 Msg4;
549 msg.is_error =
false;
550 msg.is_extended =
false;
552 msg.data = {32, 64, 12, 24};
572 EXPECT_EQ(rx0.
getLatest().header.stamp, msg.header.stamp);
573 EXPECT_EQ(rx0.
getLatest().data, msg.data);
584 typedef std_msgs::Int8 Msg1;
585 typedef std_msgs::UInt8 Msg2;
586 typedef std_msgs::Int16 Msg3;
587 typedef std_msgs::UInt16 Msg4;
613 msg.is_error =
false;
614 msg.is_extended =
false;
616 msg.data = {11, 22, 0, 33, 0, 44, 0, 0};
617 msg.data = {11, 22, 0x89, 0xAB, 0xCD, 0xEF, 0, 0};
637 EXPECT_EQ(rx0.
getLatest().header.stamp, msg.header.stamp);
638 EXPECT_EQ(rx0.
getLatest().data, msg.data);
641 EXPECT_EQ(rx3.
getLatest().data, (Msg3::_data_type)0x89AB);
642 EXPECT_EQ(rx4.
getLatest().data, (Msg4::_data_type)0xCDEF);
649 typedef std_msgs::Int32 Msg1;
650 typedef std_msgs::UInt32 Msg2;
670 msg.is_error =
false;
671 msg.is_extended =
false;
673 msg.data = {0, 0, 0, 55, 0, 0, 0, 66};
674 msg.data = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF};
690 EXPECT_EQ(rx0.
getLatest().header.stamp, msg.header.stamp);
691 EXPECT_EQ(rx0.
getLatest().data, msg.data);
692 EXPECT_EQ(rx1.
getLatest().data, (Msg1::_data_type)0x01234567);
693 EXPECT_EQ(rx2.
getLatest().data, (Msg2::_data_type)0x89ABCDEF);
700 typedef std_msgs::Int64 Msg1;
717 msg.is_error =
false;
718 msg.is_extended =
false;
720 msg.data = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xE0};
734 EXPECT_EQ(rx0.
getLatest().header.stamp, msg.header.stamp);
735 EXPECT_EQ(rx0.
getLatest().data, msg.data);
736 EXPECT_EQ(rx1.
getLatest().data, (Msg1::_data_type)0x0123456789ABCDE0);
744 typedef std_msgs::UInt64 Msg1;
761 msg.is_error =
false;
762 msg.is_extended =
false;
764 msg.data = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xE0};
778 EXPECT_EQ(rx0.
getLatest().header.stamp, msg.header.stamp);
779 EXPECT_EQ(rx0.
getLatest().data, msg.data);
780 EXPECT_EQ(rx1.
getLatest().data, (Msg1::_data_type)0x0123456789ABCDE0);
788 typedef std_msgs::UInt8 Msg1;
789 typedef std_msgs::Int8 Msg2;
790 typedef std_msgs::Int8 Msg3;
791 typedef std_msgs::UInt16 Msg4;
792 typedef std_msgs::Int32 Msg5;
816 msg.is_error =
false;
817 msg.is_extended =
false;
819 msg.data = {0, 0, 0, 0, 0, 0, 0, 0};
833 msg.data = {0x99, 0, 0, 0, 0, 0, 0, 0};
845 EXPECT_EQ(rx0.
getLatest().header.stamp, msg.header.stamp);
846 EXPECT_EQ(rx0.
getLatest().data, msg.data);
853 msg.data = {0x11, 52, 0, 0, 0, 0, 0, 0};
865 EXPECT_EQ(rx0.
getLatest().header.stamp, msg.header.stamp);
866 EXPECT_EQ(rx0.
getLatest().data, msg.data);
875 msg.data = {0x22, 102, 103, 0, 0, 0, 0, 0};
887 EXPECT_EQ(rx0.
getLatest().header.stamp, msg.header.stamp);
888 EXPECT_EQ(rx0.
getLatest().data, msg.data);
898 msg.data = {0x33, 0x78, 0x56, 0x34, 0x12, 0, 0, 0};
910 EXPECT_EQ(rx0.
getLatest().header.stamp, msg.header.stamp);
911 EXPECT_EQ(rx0.
getLatest().data, msg.data);
913 EXPECT_EQ(rx5.
getLatest().data, 0x12345678);
917 int main(
int argc,
char **argv)
924 testing::InitGoogleTest(&argc, argv);
925 return RUN_ALL_TESTS();
const ros::WallDuration DUR_A
void publish(const boost::shared_ptr< M > &message) const
bool waitPublisher(const ros::Publisher &pub, ros::WallDuration timeout)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
uint32_t getCount() const
const ros::WallDuration DUR_B
bool waitSubscriber(const ros::Subscriber &sub, ros::WallDuration timeout)
uint32_t getNumPublishers() const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
bool waitForMessage(ros::WallDuration timeout) const
uint32_t getNumSubscribers() const
int main(int argc, char **argv)
void cb(const boost::shared_ptr< MsgT const > &msg)
ros::Time getStamp() const
MsgHelper(std::string tag)