22 #include "gtest/gtest.h" 40 TEST(MapByTimeTest, AppendAndViewTrajectory) {
41 MapByTime<Data> map_by_time;
42 map_by_time.Append(0,
Data{CreateTime(10)});
43 map_by_time.Append(42,
Data{CreateTime(42)});
44 map_by_time.Append(42,
Data{CreateTime(43)});
45 std::deque<Data> expected_data = {
Data{CreateTime(42)},
Data{CreateTime(43)}};
46 for (
const Data& data : map_by_time.trajectory(42)) {
47 ASSERT_FALSE(expected_data.empty());
48 EXPECT_EQ(expected_data.front().time, data.time);
49 expected_data.pop_front();
51 EXPECT_TRUE(expected_data.empty());
54 TEST(MapByTimeTest, Trimming) {
55 MapByTime<Data> map_by_time;
56 EXPECT_FALSE(map_by_time.HasTrajectory(42));
57 map_by_time.Append(42,
Data{CreateTime(1)});
58 map_by_time.Append(42,
Data{CreateTime(41)});
59 map_by_time.Append(42,
Data{CreateTime(42)});
60 map_by_time.Append(42,
Data{CreateTime(43)});
61 map_by_time.Append(42,
Data{CreateTime(47)});
62 map_by_time.Append(42,
Data{CreateTime(48)});
63 map_by_time.Append(42,
Data{CreateTime(49)});
64 map_by_time.Append(42,
Data{CreateTime(5000)});
65 EXPECT_TRUE(map_by_time.HasTrajectory(42));
67 mapping::MapById<mapping::NodeId, NodeData> map_by_id;
68 map_by_id.Append(42, NodeData{CreateTime(42)});
69 map_by_id.Append(42, NodeData{CreateTime(46)});
70 map_by_id.Append(42, NodeData{CreateTime(48)});
71 map_by_time.Trim(map_by_id, mapping::NodeId{42, 1});
72 map_by_id.Trim(mapping::NodeId{42, 1});
73 ASSERT_TRUE(map_by_time.HasTrajectory(42));
74 std::deque<Data> expected_data = {
75 Data{CreateTime(1)},
Data{CreateTime(41)},
Data{CreateTime(42)},
76 Data{CreateTime(48)},
Data{CreateTime(49)},
Data{CreateTime(5000)}};
77 for (
const Data& data : map_by_time.trajectory(42)) {
78 ASSERT_FALSE(expected_data.empty());
79 EXPECT_EQ(expected_data.front().time, data.time);
80 expected_data.pop_front();
82 EXPECT_TRUE(expected_data.empty());
84 map_by_time.Trim(map_by_id, mapping::NodeId{42, 2});
85 map_by_id.Trim(mapping::NodeId{42, 2});
86 map_by_time.Trim(map_by_id, mapping::NodeId{42, 0});
87 map_by_id.Trim(mapping::NodeId{42, 0});
88 EXPECT_FALSE(map_by_time.HasTrajectory(42));
91 TEST(MapByTimeTest, TrimmingDoesNotCreateTrajectory) {
92 MapByTime<Data> map_by_time;
93 EXPECT_FALSE(map_by_time.HasTrajectory(42));
94 mapping::MapById<mapping::NodeId, NodeData> map_by_id;
95 map_by_id.Append(42, NodeData{CreateTime(42)});
96 map_by_time.Trim(map_by_id, mapping::NodeId{42, 0});
97 EXPECT_FALSE(map_by_time.HasTrajectory(42));
common::Duration FromMilliseconds(const int64 milliseconds)
UniversalTimeScaleClock::time_point Time
Data(const std::string &sensor_id)
TEST(TrajectoryConnectivityStateTest, UnknownTrajectory)