Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "cartographer/mapping/internal/trajectory_connectivity_state.h"
00018
00019 #include "gtest/gtest.h"
00020
00021 namespace cartographer {
00022 namespace mapping {
00023
00024 TEST(TrajectoryConnectivityStateTest, UnknownTrajectory) {
00025 TrajectoryConnectivityState state;
00026 state.Add(0);
00027
00028
00029 EXPECT_FALSE(state.TransitivelyConnected(0, 1));
00030 EXPECT_EQ(state.LastConnectionTime(0, 1), common::Time());
00031 }
00032
00033 TEST(TrajectoryConnectivityStateTest, NotConnected) {
00034 TrajectoryConnectivityState state;
00035 state.Add(0);
00036 state.Add(1);
00037 EXPECT_FALSE(state.TransitivelyConnected(0, 1));
00038 EXPECT_EQ(state.LastConnectionTime(0, 1), common::Time());
00039 }
00040
00041 TEST(TrajectoryConnectivityStateTest, Connected) {
00042 TrajectoryConnectivityState state;
00043 state.Add(0);
00044 state.Add(1);
00045 state.Connect(0, 1, common::FromUniversal(123456));
00046 EXPECT_TRUE(state.TransitivelyConnected(0, 1));
00047 EXPECT_EQ(state.LastConnectionTime(0, 1), common::FromUniversal(123456));
00048 }
00049
00050 TEST(TrajectoryConnectivityStateTest, UpdateConnectionTime) {
00051 TrajectoryConnectivityState state;
00052 state.Add(0);
00053 state.Add(1);
00054 state.Connect(0, 1, common::FromUniversal(123456));
00055 state.Connect(0, 1, common::FromUniversal(234567));
00056 EXPECT_TRUE(state.TransitivelyConnected(0, 1));
00057 EXPECT_EQ(state.LastConnectionTime(0, 1), common::FromUniversal(234567));
00058
00059
00060
00061 state.Connect(0, 1, common::FromUniversal(123456));
00062 EXPECT_EQ(state.LastConnectionTime(0, 1), common::FromUniversal(234567));
00063 }
00064
00065 TEST(TrajectoryConnectivityStateTest, JoinTwoComponents) {
00066 TrajectoryConnectivityState state;
00067 state.Add(0);
00068 state.Add(1);
00069 state.Add(2);
00070 state.Add(3);
00071 state.Connect(0, 1, common::FromUniversal(123456));
00072 state.Connect(2, 3, common::FromUniversal(123456));
00073
00074
00075 state.Connect(0, 2, common::FromUniversal(234567));
00076 EXPECT_TRUE(state.TransitivelyConnected(0, 2));
00077 EXPECT_TRUE(state.TransitivelyConnected(1, 3));
00078
00079
00080
00081 EXPECT_EQ(state.LastConnectionTime(0, 2), common::FromUniversal(234567));
00082 EXPECT_EQ(state.LastConnectionTime(0, 3), common::FromUniversal(234567));
00083 EXPECT_EQ(state.LastConnectionTime(1, 3), common::FromUniversal(234567));
00084
00085
00086
00087 EXPECT_EQ(state.LastConnectionTime(0, 1), common::FromUniversal(123456));
00088 }
00089
00090 }
00091 }