36 #include <gtest/gtest.h> 69 EXPECT_TRUE(incoming_.empty()) <<
"QueuedChecker queue not empty at time " << time
70 <<
" contains " << incoming_.front().first <<
", " << incoming_.front().second;
75 if (incoming_.empty())
77 ADD_FAILURE() <<
"QueuedChecker queue empty when checking " << time <<
", " << data;
81 std::pair<double, int> &head = incoming_.front();
83 EXPECT_EQ(time, head.first) <<
"Timestamp mismatch when checking " << time <<
", " << data;
84 EXPECT_EQ(data, head.second) <<
"Data mismatch when checking " << time <<
", " << data;
91 incoming_.push(std::pair<double, int>(time.
toSec(), *data));
95 TEST(QueuedTriggerMatcher, BasicFunctionality)
134 TEST(QueuedTriggerMatcher, TestReset)
172 TEST(QueuedTriggerMatcher, MissingTrigger)
191 TEST(QueuedTriggerMatcher, MissingData)
220 TEST(QueuedTriggerMatcher, MissingDataZeroLateTolerance)
253 TEST(QueuedTriggerMatcher, TriggerQueueOverflow)
257 double trig_time = 4;
258 for (
int i = 0; i < 15; i++)
269 TEST(QueuedTriggerMatcher, DataQueueOverflow)
273 double data_time = 5;
274 for (
int i = 0; i < 10; i++)
285 TEST(TriggerMatcher, TimeoutCheck)
293 TEST(TriggerMatcher, TriggerFirstCheck)
305 TEST(TriggerMatcher, TestReset)
326 TEST(TriggerMatcher, DataFirstCheck)
331 boost::function<void(void)> agt = boost::bind(&
AsyncGenTrigger, &tm, 7.0, 2);
332 boost::thread trigger_thread(agt);
337 trigger_thread.join();
341 int main(
int argc,
char **argv){
342 for (
int i = 0; i < argc; i++)
343 printf(
"%s\n", argv[i]);
344 testing::InitGoogleTest(&argc, argv);
345 return RUN_ALL_TESTS();
TEST(QueuedTriggerMatcher, BasicFunctionality)
int main(int argc, char **argv)
void expectEmpty(double time)
void callback(const ros::Time &time, const boost::shared_ptr< int const > &data)
std::queue< std::pair< double, int > > incoming_
timestamp_tools::QueuedTriggerMatcher< int > tm
void AsyncGenTrigger(timestamp_tools::TriggerMatcher *tm, double time, int delay)
void expectHead(double time, int data)