Branch data Line data Source code
1 : : // ----------------- BEGIN LICENSE BLOCK ---------------------------------
2 : : //
3 : : // Copyright (C) 2019-2021 Intel Corporation
4 : : //
5 : : // SPDX-License-Identifier: LGPL-2.1-only
6 : : //
7 : : // ----------------- END LICENSE BLOCK -----------------------------------
8 : :
9 : : #include "RssCheckTestBaseT.hpp"
10 : : #include "ad/rss/structured/RssConstellationIdProvider.hpp"
11 : :
12 : : namespace ad {
13 : : namespace rss {
14 : : namespace structured {
15 : :
16 : : class RssConstellationIdProviderTests : public core::RssCheckTestBaseT<testing::Test>
17 : : {
18 : : public:
19 : 10 : world::Object &getEgoObject() override
20 : : {
21 : 10 : return objectOnSegment0;
22 : : }
23 : :
24 : 10 : world::Object &getConstellationObject(uint32_t) override
25 : : {
26 : 10 : return objectOnSegment8;
27 : : }
28 : :
29 : 20 : world::ConstellationType getConstellationType() override
30 : : {
31 : 20 : return world::ConstellationType::IntersectionEgoHasPriority;
32 : : }
33 : :
34 : : RssConstellationIdProvider constellationIdProvider;
35 : : };
36 : :
37 : 4 : TEST_F(RssConstellationIdProviderTests, same_constellation_result_in_same_constellations)
38 : : {
39 : : auto const firstConstellationId
40 [ + - ]: 1 : = constellationIdProvider.getConstellationId(worldModel.time_index, worldModel.constellations[0]);
41 : : auto secondConstellationId
42 [ + - ]: 1 : = constellationIdProvider.getConstellationId(worldModel.time_index, worldModel.constellations[0]);
43 [ + - - + : 1 : EXPECT_EQ(firstConstellationId, secondConstellationId);
- - - - -
- ]
44 : :
45 : 1 : worldModel.time_index++;
46 : : secondConstellationId
47 [ + - ]: 1 : = constellationIdProvider.getConstellationId(worldModel.time_index, worldModel.constellations[0]);
48 [ + - - + : 1 : EXPECT_EQ(firstConstellationId, secondConstellationId);
- - - - -
- ]
49 : 1 : }
50 : :
51 : 4 : TEST_F(RssConstellationIdProviderTests, different_objectids_result_in_different_constellations)
52 : : {
53 : : auto const firstConstellationId
54 [ + - ]: 1 : = constellationIdProvider.getConstellationId(worldModel.time_index, worldModel.constellations[0]);
55 : 1 : worldModel.constellations[0].object.object_id = 49;
56 : : auto const secondConstellationId
57 [ + - ]: 1 : = constellationIdProvider.getConstellationId(worldModel.time_index, worldModel.constellations[0]);
58 [ + - - + : 1 : EXPECT_NE(firstConstellationId, secondConstellationId);
- - - - -
- ]
59 : 1 : }
60 : :
61 : 4 : TEST_F(RssConstellationIdProviderTests, different_constellation_types_result_in_different_constellations)
62 : : {
63 : : auto const firstConstellationId
64 [ + - ]: 1 : = constellationIdProvider.getConstellationId(worldModel.time_index, worldModel.constellations[0]);
65 : 1 : worldModel.constellations[0].constellation_type = world::ConstellationType::IntersectionObjectHasPriority;
66 : : auto const secondConstellationId
67 [ + - ]: 1 : = constellationIdProvider.getConstellationId(worldModel.time_index, worldModel.constellations[0]);
68 [ + - - + : 1 : EXPECT_NE(firstConstellationId, secondConstellationId);
- - - - -
- ]
69 : 1 : }
70 : :
71 : 4 : TEST_F(RssConstellationIdProviderTests, different_ego_intersection_route_id_result_in_different_constellations)
72 : : {
73 : : auto const firstConstellationId
74 [ + - ]: 1 : = constellationIdProvider.getConstellationId(worldModel.time_index, worldModel.constellations[0]);
75 : :
76 : 1 : worldModel.constellations[0].ego_vehicle_road.back().lane_segments.back().id = 88;
77 : : auto secondConstellationId
78 [ + - ]: 1 : = constellationIdProvider.getConstellationId(worldModel.time_index, worldModel.constellations[0]);
79 [ + - - + : 1 : EXPECT_NE(firstConstellationId, secondConstellationId);
- - - - -
- ]
80 : 1 : }
81 : :
82 : 4 : TEST_F(RssConstellationIdProviderTests, different_object_intersection_route_id_result_in_different_constellations)
83 : : {
84 : : auto const firstConstellationId
85 [ + - ]: 1 : = constellationIdProvider.getConstellationId(worldModel.time_index, worldModel.constellations[0]);
86 : :
87 : 1 : worldModel.constellations[0].intersecting_road.back().lane_segments.back().id = 99;
88 : : auto secondConstellationId
89 [ + - ]: 1 : = constellationIdProvider.getConstellationId(worldModel.time_index, worldModel.constellations[0]);
90 [ + - - + : 1 : EXPECT_NE(firstConstellationId, secondConstellationId);
- - - - -
- ]
91 : 1 : }
92 : :
93 : 4 : TEST_F(RssConstellationIdProviderTests, different_ego_intersection_route_size_result_in_different_constellations)
94 : : {
95 : : auto const firstConstellationId
96 [ + - ]: 1 : = constellationIdProvider.getConstellationId(worldModel.time_index, worldModel.constellations[0]);
97 : :
98 [ + - ]: 2 : worldModel.constellations[0].ego_vehicle_road.back().lane_segments.push_back(
99 : 1 : worldModel.constellations[0].ego_vehicle_road.back().lane_segments.back());
100 : 1 : worldModel.constellations[0].ego_vehicle_road.back().lane_segments.back().id = 88;
101 : : auto secondConstellationId
102 [ + - ]: 1 : = constellationIdProvider.getConstellationId(worldModel.time_index, worldModel.constellations[0]);
103 [ + - - + : 1 : EXPECT_NE(firstConstellationId, secondConstellationId);
- - - - -
- ]
104 : 1 : }
105 : :
106 : 4 : TEST_F(RssConstellationIdProviderTests, different_object_intersection_route_size_result_in_different_constellations)
107 : : {
108 : : auto const firstConstellationId
109 [ + - ]: 1 : = constellationIdProvider.getConstellationId(worldModel.time_index, worldModel.constellations[0]);
110 : :
111 [ + - ]: 2 : worldModel.constellations[0].intersecting_road.back().lane_segments.push_back(
112 : 1 : worldModel.constellations[0].intersecting_road.back().lane_segments.back());
113 : 1 : worldModel.constellations[0].intersecting_road.back().lane_segments.back().id = 99;
114 : : auto secondConstellationId
115 [ + - ]: 1 : = constellationIdProvider.getConstellationId(worldModel.time_index, worldModel.constellations[0]);
116 [ + - - + : 1 : EXPECT_NE(firstConstellationId, secondConstellationId);
- - - - -
- ]
117 : 1 : }
118 : :
119 : 4 : TEST_F(RssConstellationIdProviderTests, different_ego_non_intersection_route_size_result_in_same_constellations)
120 : : {
121 : : auto const firstConstellationId
122 [ + - ]: 1 : = constellationIdProvider.getConstellationId(worldModel.time_index, worldModel.constellations[0]);
123 : :
124 [ + - ]: 1 : worldModel.constellations[0].ego_vehicle_road.erase(worldModel.constellations[0].ego_vehicle_road.begin());
125 : : auto secondConstellationId
126 [ + - ]: 1 : = constellationIdProvider.getConstellationId(worldModel.time_index, worldModel.constellations[0]);
127 [ + - - + : 1 : EXPECT_EQ(firstConstellationId, secondConstellationId);
- - - - -
- ]
128 : 1 : }
129 : :
130 : 4 : TEST_F(RssConstellationIdProviderTests, different_object_non_intersection_route_size_result_in_same_constellations)
131 : : {
132 : : auto const firstConstellationId
133 [ + - ]: 1 : = constellationIdProvider.getConstellationId(worldModel.time_index, worldModel.constellations[0]);
134 : :
135 [ + - ]: 1 : worldModel.constellations[0].intersecting_road.erase(worldModel.constellations[0].intersecting_road.begin());
136 : : auto secondConstellationId
137 [ + - ]: 1 : = constellationIdProvider.getConstellationId(worldModel.time_index, worldModel.constellations[0]);
138 [ + - - + : 1 : EXPECT_EQ(firstConstellationId, secondConstellationId);
- - - - -
- ]
139 : 1 : }
140 : :
141 : 4 : TEST_F(RssConstellationIdProviderTests, history_is_cleaned)
142 : : {
143 : 1 : auto const originalObjectId = worldModel.constellations[0].object.object_id;
144 : : auto const firstConstellationId
145 [ + - ]: 1 : = constellationIdProvider.getConstellationId(worldModel.time_index, worldModel.constellations[0]);
146 : :
147 : 1 : worldModel.constellations[0].object.object_id = 49;
148 : : auto const secondConstellationId
149 [ + - ]: 1 : = constellationIdProvider.getConstellationId(worldModel.time_index, worldModel.constellations[0]);
150 [ + - - + : 1 : EXPECT_NE(firstConstellationId, secondConstellationId);
- - - - -
- ]
151 : :
152 : 1 : worldModel.time_index++;
153 : : auto thirdConstellationId
154 [ + - ]: 1 : = constellationIdProvider.getConstellationId(worldModel.time_index, worldModel.constellations[0]);
155 [ + - - + : 1 : EXPECT_EQ(secondConstellationId, thirdConstellationId);
- - - - -
- ]
156 : :
157 : 1 : worldModel.time_index++;
158 : : // 49 still tracked
159 : : thirdConstellationId
160 [ + - ]: 1 : = constellationIdProvider.getConstellationId(worldModel.time_index, worldModel.constellations[0]);
161 [ + - - + : 1 : EXPECT_EQ(secondConstellationId, thirdConstellationId);
- - - - -
- ]
162 : :
163 : : // original already forgotten
164 : 1 : worldModel.constellations[0].object.object_id = originalObjectId;
165 : : auto fourthConstellationId
166 [ + - ]: 1 : = constellationIdProvider.getConstellationId(worldModel.time_index, worldModel.constellations[0]);
167 [ + - - + : 1 : EXPECT_NE(firstConstellationId, fourthConstellationId);
- - - - -
- ]
168 : 1 : }
169 : :
170 : : } // namespace structured
171 : : } // namespace rss
172 : : } // namespace ad
|