18 #include "cartographer/mapping/proto/pose_graph.pb.h" 19 #include "cartographer/mapping/proto/serialization.pb.h" 21 #include "gtest/gtest.h" 28 using google::protobuf::Message;
29 using mapping::proto::PoseGraph;
30 using mapping::proto::SerializedData;
32 class InMemoryProtoStreamTest :
public ::testing::Test {
34 void SetUp()
override {
43 TEST_F(InMemoryProtoStreamTest, ReadStreamInitializedFromQueue) {
44 std::queue<std::unique_ptr<Message>> proto_queue;
45 proto_queue.push(make_unique<PoseGraph>(
pose_graph_));
48 InMemoryProtoStreamReader reader(std::move(proto_queue));
50 PoseGraph actual_pose_graph;
51 EXPECT_FALSE(reader.eof());
52 EXPECT_TRUE(reader.ReadProto(&actual_pose_graph));
53 EXPECT_EQ(1, actual_pose_graph.trajectory(0).trajectory_id());
55 SerializedData actual_serialized_data;
56 EXPECT_FALSE(reader.eof());
57 EXPECT_TRUE(reader.ReadProto(&actual_serialized_data));
58 EXPECT_EQ(2, actual_serialized_data.odometry_data().trajectory_id());
60 EXPECT_TRUE(reader.eof());
63 TEST_F(InMemoryProtoStreamTest, ReadStreamInitializedIncrementally) {
64 InMemoryProtoStreamReader reader;
68 PoseGraph actual_pose_graph;
69 EXPECT_FALSE(reader.eof());
70 EXPECT_TRUE(reader.ReadProto(&actual_pose_graph));
71 EXPECT_EQ(1, actual_pose_graph.trajectory(0).trajectory_id());
73 SerializedData actual_serialized_data;
74 EXPECT_FALSE(reader.eof());
75 EXPECT_TRUE(reader.ReadProto(&actual_serialized_data));
76 EXPECT_EQ(2, actual_serialized_data.odometry_data().trajectory_id());
78 EXPECT_TRUE(reader.eof());
_Unique_if< T >::_Single_object make_unique(Args &&... args)
SerializedData serialized_data_