MCPcopy Create free account
hub / github.com/AdaCompNUS/summit / test_roads

Function test_roads

LibCarla/source/test/client/test_opendrive.cpp:117–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115}
116
117static void test_roads(const pugi::xml_document &xml, boost::optional<Map>& map) {
118 pugi::xml_node open_drive_node = xml.child("OpenDRIVE");
119
120 // Check total Roads
121 auto roads_parser = open_drive_node.children("road");
122 auto total_roads_parser = std::distance(roads_parser.begin(), roads_parser.end());
123 auto total_roads = map->GetMap().GetRoads().size();
124 ASSERT_EQ(total_roads, total_roads_parser);
125
126 for (pugi::xml_node road_node : roads_parser) {
127 RoadId road_id = road_node.attribute("id").as_uint();
128
129 for (pugi::xml_node lanes_node : road_node.children("lanes")) {
130
131 // Check total Lane Sections
132 auto lane_sections_parser = lanes_node.children("laneSection");
133 auto total_lane_sections_parser = std::distance(lane_sections_parser.begin(), lane_sections_parser.end());
134 auto total_lane_sections = map->GetMap().GetRoad(road_id).GetLaneSections().size();
135 ASSERT_EQ(total_lane_sections, total_lane_sections_parser);
136
137 for (pugi::xml_node lane_section_node : lane_sections_parser) {
138
139 // Check total Lanes
140 const double s = lane_section_node.attribute("s").as_double();
141 auto lane_section = map->GetMap().GetRoad(road_id).GetLaneSectionsAt(s);
142 size_t total_lanes = 0u;
143 for (auto it = lane_section.begin(); it != lane_section.end(); ++it) {
144 total_lanes = it->GetLanes().size();
145 }
146 auto left_nodes = lane_section_node.child("left").children("lane");
147 auto center_nodes = lane_section_node.child("center").children("lane");
148 auto right_nodes = lane_section_node.child("right").children("lane");
149 auto total_lanes_parser = std::distance(left_nodes.begin(), left_nodes.end());
150 total_lanes_parser += std::distance(right_nodes.begin(), right_nodes.end());
151 total_lanes_parser += std::distance(center_nodes.begin(), center_nodes.end());
152
153 ASSERT_EQ(total_lanes, total_lanes_parser);
154
155
156 auto total_road_mark = 0;
157 auto total_road_mark_parser = 0;
158 for (auto it = lane_section.begin(); it != lane_section.end(); ++it) {
159 auto total_left = get_total_road_marks(left_nodes, *it);
160 auto total_center = get_total_road_marks(center_nodes, *it);
161 auto total_right = get_total_road_marks(right_nodes, *it);
162 total_road_mark = total_left.first + total_center.first + total_right.first;
163 total_road_mark_parser = total_left.first + total_center.first + total_right.first;
164 }
165 ASSERT_EQ(total_road_mark, total_road_mark_parser);
166 }
167 }
168 }
169}
170
171// Junctions
172static void test_junctions(const pugi::xml_document &xml, boost::optional<Map>& map) {

Callers 1

TESTFunction · 0.85

Calls 13

get_total_road_marksFunction · 0.85
childMethod · 0.80
childrenMethod · 0.80
as_uintMethod · 0.80
attributeMethod · 0.80
GetLaneSectionsMethod · 0.80
as_doubleMethod · 0.80
GetLaneSectionsAtMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
GetMapMethod · 0.45

Tested by

no test coverage detected