36 #include <gtest/gtest.h> 57 for (
unsigned int i=start; i < end; i++)
76 EXPECT_EQ(interval_data.size(), (
unsigned int) 3) ;
77 EXPECT_EQ(interval_data[0].data, 1) ;
78 EXPECT_EQ(interval_data[1].data, 2) ;
79 EXPECT_EQ(interval_data[2].data, 3) ;
83 EXPECT_EQ(interval_data.size(), (
unsigned int) 0) ;
88 EXPECT_EQ(interval_data.size(), (
unsigned int) 0) ;
97 vector<Msg> interval_data;
99 EXPECT_EQ(interval_data.size(), (
unsigned int) 4);
100 EXPECT_EQ(interval_data[0].data, 1);
101 EXPECT_EQ(interval_data[1].data, 2);
102 EXPECT_EQ(interval_data[2].data, 3);
103 EXPECT_EQ(interval_data[3].data, 4);
106 EXPECT_EQ(interval_data.size(), (
unsigned int) 4);
107 EXPECT_EQ(interval_data[0].data, 1);
110 EXPECT_EQ(interval_data.size(), (
unsigned int) 2);
111 EXPECT_EQ(interval_data[0].data, 3);
112 EXPECT_EQ(interval_data[1].data, 4);
115 EXPECT_EQ(interval_data.size(), (
unsigned int) 1);
116 EXPECT_EQ(interval_data[0].data, 5);
140 EXPECT_EQ(interval_data.size(), (
unsigned int) 2) ;
141 EXPECT_EQ(interval_data[0].data, 0) ;
142 EXPECT_EQ(interval_data[1].data, 1) ;
146 EXPECT_EQ(interval_data.size(), (
unsigned int) 5) ;
147 EXPECT_EQ(interval_data[0].data, 0) ;
148 EXPECT_EQ(interval_data[1].data, 1) ;
149 EXPECT_EQ(interval_data[2].data, 2) ;
150 EXPECT_EQ(interval_data[3].data, 3) ;
151 EXPECT_EQ(interval_data[4].data, 7) ;
166 EXPECT_EQ(elem.
data, 9);
169 ASSERT_TRUE(result) ;
170 EXPECT_EQ(elem.
data, 8) ;
173 EXPECT_FALSE(result) ;
183 vector<Msg> interval_data;
185 EXPECT_EQ(interval_data.size(), (
unsigned int) 9) ;
189 EXPECT_EQ(interval_data.size(), (
unsigned int) 6);
190 EXPECT_EQ(interval_data[0].data, 4) ;
191 EXPECT_EQ(interval_data[1].data, 5) ;
192 EXPECT_EQ(interval_data[2].data, 6) ;
193 EXPECT_EQ(interval_data[3].data, 7) ;
194 EXPECT_EQ(interval_data[4].data, 8) ;
195 EXPECT_EQ(interval_data[5].data, 9) ;
210 EXPECT_EQ(elem.
data, 1) ;
214 EXPECT_EQ(elem.
data, 2) ;
228 msg_ptr.reset(
new Msg);
232 msg_ptr.reset(
new Msg);
241 EXPECT_EQ(found_elem->header.stamp,
ros::Time(20,0));
246 int main(
int argc,
char **argv){
247 testing::InitGoogleTest(&argc, argv);
248 return RUN_ALL_TESTS();
Adds helper routines to the STL Deque for holding messages with headers.
void setMaxSize(unsigned int max_size)
Set the maximum # of elements this deque can hold. Older elems are popped once the length is exeeded...
bool getClosestElem(const ros::Time &time, M &out)
Get the elem that occurs closest to the specified time.
bool getElemAfterTime(const ros::Time &time, M &out) const
Grab the oldest element that occurs right after the specified time.
bool getElemBeforeTime(const ros::Time &time, M &out) const
Grab the oldest element that occurs right before the specified time.
void add(const M &msg)
Add a new element to the deque, correctly sorted by timestamp.
TEST(SortedDeque, easyInterval)
Msg buildMsg(double time, int data)
int main(int argc, char **argv)
std::vector< M > getSurroundingInterval(const ros::Time &start, const ros::Time &end)
void fillEasy(SortedDeque< Msg > &sd, unsigned int start, unsigned int end)
void removeAllBeforeTime(const ros::Time &time)
Removes all elements that occur before the specified time.
std::vector< M > getInterval(const ros::Time &start, const ros::Time &end)
Extract all the elements that occur in the interval between the start and end times.