LCOV - code coverage report
Current view: top level - tests/core - RssCheckConstellationTests.cpp (source / functions) Hit Total Coverage
Test: ad_rss Lines: 77 84 91.7 %
Date: 2025-07-22 06:53:46 Functions: 27 30 90.0 %
Branches: 78 250 31.2 %

           Branch data     Line data    Source code
       1                 :            : // ----------------- BEGIN LICENSE BLOCK ---------------------------------
       2                 :            : //
       3                 :            : // Copyright (C) 2018-2021 Intel Corporation
       4                 :            : //
       5                 :            : // SPDX-License-Identifier: LGPL-2.1-only
       6                 :            : //
       7                 :            : // ----------------- END LICENSE BLOCK -----------------------------------
       8                 :            : 
       9                 :            : #include <chrono>
      10                 :            : #include "RssCheckTestBaseT.hpp"
      11                 :            : 
      12                 :            : namespace ad {
      13                 :            : namespace rss {
      14                 :            : namespace core {
      15                 :            : 
      16                 :            : class RssCheckConstellationTests : public RssCheckTestBaseT<testing::Test>
      17                 :            : {
      18                 :            : };
      19                 :            : 
      20                 :          4 : TEST_F(RssCheckConstellationTests, EmptyEgoRoadSegment)
      21                 :            : {
      22                 :          1 :   state::ProperResponse properResponse;
      23         [ +  - ]:          1 :   core::RssCheck rssCheck;
      24                 :            : 
      25                 :          1 :   worldModel.constellations[0].ego_vehicle_road[0].lane_segments.clear();
      26                 :            : 
      27   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
      28   [ +  -  +  - ]:          1 : }
      29                 :            : 
      30                 :          4 : TEST_F(RssCheckConstellationTests, EmptyEgoRoad)
      31                 :            : {
      32                 :          1 :   state::ProperResponse properResponse;
      33         [ +  - ]:          1 :   core::RssCheck rssCheck;
      34                 :            : 
      35                 :          1 :   worldModel.constellations[0].ego_vehicle_road.clear();
      36                 :            : 
      37   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
      38   [ +  -  +  - ]:          1 : }
      39                 :            : 
      40                 :          4 : TEST_F(RssCheckConstellationTests, EgoRoadIncomplete)
      41                 :            : {
      42                 :          1 :   state::ProperResponse properResponse;
      43         [ +  - ]:          1 :   core::RssCheck rssCheck;
      44                 :            : 
      45                 :          1 :   worldModel.constellations[0].ego_vehicle_road[1].lane_segments.clear();
      46                 :            : 
      47   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
      48   [ +  -  +  - ]:          1 : }
      49                 :            : 
      50                 :          4 : TEST_F(RssCheckConstellationTests, IntersectionRoadButNotExpected)
      51                 :            : {
      52                 :          1 :   state::ProperResponse properResponse;
      53         [ +  - ]:          1 :   core::RssCheck rssCheck;
      54                 :            : 
      55         [ +  - ]:          1 :   worldModel.constellations[0].intersecting_road = worldModel.constellations[0].ego_vehicle_road;
      56                 :            : 
      57   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
      58   [ +  -  +  - ]:          1 : }
      59                 :            : 
      60                 :          4 : TEST_F(RssCheckConstellationTests, NoIntersectionRoadButExpected)
      61                 :            : {
      62                 :          1 :   state::ProperResponse properResponse;
      63         [ +  - ]:          1 :   core::RssCheck rssCheck;
      64                 :            : 
      65                 :          1 :   worldModel.constellations[0].constellation_type = world::ConstellationType::IntersectionEgoHasPriority;
      66                 :            : 
      67   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
      68   [ +  -  +  - ]:          1 : }
      69                 :            : 
      70                 :          0 : TEST_F(RssCheckConstellationTests, DISABLED_IntersectionRoadButNotIntersecting)
      71                 :            : {
      72                 :            :   // todo: currently this is not reported anymore as actual error
      73                 :          0 :   state::ProperResponse properResponse;
      74         [ #  # ]:          0 :   core::RssCheck rssCheck;
      75                 :            : 
      76                 :          0 :   worldModel.constellations[0].constellation_type = world::ConstellationType::IntersectionEgoHasPriority;
      77         [ #  # ]:          0 :   worldModel.constellations[0].intersecting_road = worldModel.constellations[0].ego_vehicle_road;
      78                 :            : 
      79   [ #  #  #  #  :          0 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          #  #  #  #  #  
             #  #  #  #  
                      # ]
      80   [ #  #  #  # ]:          0 : }
      81                 :            : 
      82                 :          4 : TEST_F(RssCheckConstellationTests, EmptyConstellation)
      83                 :            : {
      84                 :          1 :   state::ProperResponse properResponse;
      85         [ +  - ]:          1 :   core::RssCheck rssCheck;
      86                 :            : 
      87                 :          1 :   worldModel.constellations.clear();
      88                 :            : 
      89   [ +  -  -  +  :          1 :   ASSERT_TRUE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
      90         [ +  - ]:          1 :   testRestrictions(properResponse.acceleration_restrictions);
      91   [ +  -  +  - ]:          1 : }
      92                 :            : 
      93                 :          4 : TEST_F(RssCheckConstellationTests, MaximumConstellationSize)
      94                 :            : {
      95         [ +  - ]:          1 :   auto const basicConstellation = worldModel.constellations[0];
      96                 :            : 
      97         [ +  - ]:          1 :   world::RoadSegment maximumRoadSegment = basicConstellation.ego_vehicle_road[0];
      98         [ +  - ]:          1 :   maximumRoadSegment.lane_segments.resize(20u, basicConstellation.ego_vehicle_road[0].lane_segments[0]);
      99                 :            : 
     100         [ +  - ]:          1 :   world::Constellation maximumConstellation = basicConstellation;
     101         [ +  - ]:          1 :   maximumConstellation.ego_vehicle_road.resize(50u, maximumRoadSegment);
     102         [ +  + ]:         51 :   for (size_t roadSegmentCount = 0u; roadSegmentCount < maximumConstellation.ego_vehicle_road.size();
     103                 :            :        roadSegmentCount++)
     104                 :            :   {
     105                 :         50 :     auto &roadSegment = maximumConstellation.ego_vehicle_road[roadSegmentCount];
     106         [ +  + ]:        999 :     for (size_t laneSegmentCount = 0u; laneSegmentCount < roadSegment.lane_segments.size(); laneSegmentCount++)
     107                 :            :     {
     108                 :        949 :       roadSegment.lane_segments[laneSegmentCount].id = roadSegmentCount * 1000u + 100u + laneSegmentCount;
     109                 :            :     }
     110                 :            :   }
     111                 :          1 :   maximumConstellation.ego_vehicle_road[0].lane_segments[0].id = 1;
     112                 :          1 :   maximumConstellation.ego_vehicle_road[49].lane_segments[19].id = 7;
     113                 :            : 
     114                 :          1 :   world::ConstellationVector maximumConstellationVector;
     115         [ +  - ]:          1 :   maximumConstellationVector.resize(100, maximumConstellation);
     116         [ +  + ]:        101 :   for (size_t constellationCount = 0u; constellationCount < maximumConstellationVector.size(); constellationCount++)
     117                 :            :   {
     118                 :        100 :     maximumConstellationVector[constellationCount].object.object_id = constellationCount + 10u;
     119                 :            :   }
     120                 :            : 
     121         [ +  - ]:          1 :   worldModel.constellations = maximumConstellationVector;
     122                 :          1 :   state::ProperResponse properResponse;
     123         [ +  - ]:          1 :   core::RssCheck rssCheck;
     124                 :            : 
     125                 :          1 :   auto const start = std::chrono::system_clock::now();
     126                 :            : 
     127   [ +  -  -  +  :          1 :   ASSERT_TRUE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
     128         [ +  - ]:          1 :   testRestrictions(properResponse.acceleration_restrictions);
     129                 :            : 
     130                 :          1 :   auto const end = std::chrono::system_clock::now();
     131   [ +  -  +  - ]:          1 :   auto const diff = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
     132                 :            : 
     133                 :            :   // in debug build we should be below 500 ms
     134   [ +  -  -  +  :          1 :   EXPECT_LE(diff.count(), 500);
          -  -  -  -  -  
                      - ]
     135   [ +  -  +  -  :          1 : }
          +  -  +  -  +  
                -  +  - ]
     136                 :            : 
     137                 :          4 : TEST_F(RssCheckConstellationTests, WrongEgoRoadMetricRangeLength)
     138                 :            : {
     139                 :          1 :   state::ProperResponse properResponse;
     140         [ +  - ]:          1 :   core::RssCheck rssCheck;
     141                 :            : 
     142                 :          1 :   worldModel.constellations[0].ego_vehicle_road[0].lane_segments[0].length.minimum = Distance(10);
     143                 :          1 :   worldModel.constellations[0].ego_vehicle_road[0].lane_segments[0].length.maximum = Distance(5);
     144   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
     145   [ +  -  +  - ]:          1 : }
     146                 :            : 
     147                 :          4 : TEST_F(RssCheckConstellationTests, WrongEgoRoadMetricRangeWidth)
     148                 :            : {
     149                 :          1 :   state::ProperResponse properResponse;
     150         [ +  - ]:          1 :   core::RssCheck rssCheck;
     151                 :            : 
     152                 :          1 :   worldModel.constellations[0].ego_vehicle_road[0].lane_segments[0].width.minimum = Distance(10);
     153                 :          1 :   worldModel.constellations[0].ego_vehicle_road[0].lane_segments[0].width.maximum = Distance(5);
     154   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
     155   [ +  -  +  - ]:          1 : }
     156                 :            : 
     157                 :            : } // namespace core
     158                 :            : } // namespace rss
     159                 :            : } // namespace ad

Generated by: LCOV version 1.14