LCOV - code coverage report
Current view: top level - tests/core - RssCheckSceneTests.cpp (source / functions) Hit Total Coverage
Test: ad_rss Lines: 74 74 100.0 %
Date: 2024-04-23 14:35:54 Functions: 20 20 100.0 %
Branches: 51 182 28.0 %

           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 RssCheckSceneTests : public RssCheckTestBaseT<testing::Test>
      17                 :            : {
      18                 :            : };
      19                 :            : 
      20                 :          2 : TEST_F(RssCheckSceneTests, EmptyEgoRoadSegment)
      21                 :            : {
      22                 :          1 :   state::ProperResponse properResponse;
      23         [ +  - ]:          1 :   core::RssCheck rssCheck;
      24                 :            : 
      25                 :          1 :   worldModel.scenes[0].egoVehicleRoad[0].clear();
      26                 :            : 
      27   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
                -  -  - ]
      28                 :            : }
      29                 :            : 
      30                 :          2 : TEST_F(RssCheckSceneTests, EmptyEgoRoad)
      31                 :            : {
      32                 :          1 :   state::ProperResponse properResponse;
      33         [ +  - ]:          1 :   core::RssCheck rssCheck;
      34                 :            : 
      35                 :          1 :   worldModel.scenes[0].egoVehicleRoad.clear();
      36                 :            : 
      37   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
                -  -  - ]
      38                 :            : }
      39                 :            : 
      40                 :          2 : TEST_F(RssCheckSceneTests, EgoRoadIncomplete)
      41                 :            : {
      42                 :          1 :   state::ProperResponse properResponse;
      43         [ +  - ]:          1 :   core::RssCheck rssCheck;
      44                 :            : 
      45                 :          1 :   worldModel.scenes[0].egoVehicleRoad[1].clear();
      46                 :            : 
      47   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
                -  -  - ]
      48                 :            : }
      49                 :            : 
      50                 :          2 : TEST_F(RssCheckSceneTests, IntersectionRoadButNotExpected)
      51                 :            : {
      52                 :          1 :   state::ProperResponse properResponse;
      53         [ +  - ]:          1 :   core::RssCheck rssCheck;
      54                 :            : 
      55         [ +  - ]:          1 :   worldModel.scenes[0].intersectingRoad = worldModel.scenes[0].egoVehicleRoad;
      56                 :            : 
      57   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
                -  -  - ]
      58                 :            : }
      59                 :            : 
      60                 :          2 : TEST_F(RssCheckSceneTests, NoIntersectionRoadButExpected)
      61                 :            : {
      62                 :          1 :   state::ProperResponse properResponse;
      63         [ +  - ]:          1 :   core::RssCheck rssCheck;
      64                 :            : 
      65                 :          1 :   worldModel.scenes[0].situationType = situation::SituationType::IntersectionEgoHasPriority;
      66                 :            : 
      67   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
                -  -  - ]
      68                 :            : }
      69                 :            : 
      70                 :          2 : TEST_F(RssCheckSceneTests, IntersectionRoadButNotIntersecting)
      71                 :            : {
      72                 :          1 :   state::ProperResponse properResponse;
      73         [ +  - ]:          1 :   core::RssCheck rssCheck;
      74                 :            : 
      75                 :          1 :   worldModel.scenes[0].situationType = situation::SituationType::IntersectionEgoHasPriority;
      76         [ +  - ]:          1 :   worldModel.scenes[0].intersectingRoad = worldModel.scenes[0].egoVehicleRoad;
      77                 :            : 
      78   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
                -  -  - ]
      79                 :            : }
      80                 :            : 
      81                 :          2 : TEST_F(RssCheckSceneTests, EmptyScene)
      82                 :            : {
      83                 :          1 :   state::ProperResponse properResponse;
      84         [ +  - ]:          1 :   core::RssCheck rssCheck;
      85                 :            : 
      86                 :          1 :   worldModel.scenes.clear();
      87                 :            : 
      88   [ +  -  -  +  :          1 :   ASSERT_TRUE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
                -  -  - ]
      89         [ +  - ]:          1 :   testRestrictions(properResponse.accelerationRestrictions);
      90                 :            : }
      91                 :            : 
      92                 :          2 : TEST_F(RssCheckSceneTests, MaximumSceneSize)
      93                 :            : {
      94         [ +  - ]:          1 :   auto const basicScene = worldModel.scenes[0];
      95                 :            : 
      96         [ +  - ]:          1 :   world::RoadSegment maximumRoadSegment = basicScene.egoVehicleRoad[0];
      97         [ +  - ]:          1 :   maximumRoadSegment.resize(20u, basicScene.egoVehicleRoad[0][0]);
      98                 :            : 
      99         [ +  - ]:          1 :   world::Scene maximumScene = basicScene;
     100         [ +  - ]:          1 :   maximumScene.egoVehicleRoad.resize(50u, maximumRoadSegment);
     101         [ +  + ]:         51 :   for (size_t roadSegmentCount = 0u; roadSegmentCount < maximumScene.egoVehicleRoad.size(); roadSegmentCount++)
     102                 :            :   {
     103                 :         50 :     auto &roadSegment = maximumScene.egoVehicleRoad[roadSegmentCount];
     104         [ +  + ]:        999 :     for (size_t laneSegmentCount = 0u; laneSegmentCount < roadSegment.size(); laneSegmentCount++)
     105                 :            :     {
     106                 :        949 :       roadSegment[laneSegmentCount].id = roadSegmentCount * 1000u + 100u + laneSegmentCount;
     107                 :            :     }
     108                 :            :   }
     109                 :          1 :   maximumScene.egoVehicleRoad[0][0].id = 1;
     110                 :          1 :   maximumScene.egoVehicleRoad[49][19].id = 7;
     111                 :            : 
     112                 :          1 :   world::SceneVector maximumSceneVector;
     113         [ +  - ]:          1 :   maximumSceneVector.resize(100, maximumScene);
     114         [ +  + ]:        101 :   for (size_t sceneCount = 0u; sceneCount < maximumSceneVector.size(); sceneCount++)
     115                 :            :   {
     116                 :        100 :     maximumSceneVector[sceneCount].object.objectId = sceneCount + 10u;
     117                 :            :   }
     118                 :            : 
     119         [ +  - ]:          1 :   worldModel.scenes = maximumSceneVector;
     120                 :          1 :   state::ProperResponse properResponse;
     121         [ +  - ]:          1 :   core::RssCheck rssCheck;
     122                 :            : 
     123                 :          1 :   auto const start = std::chrono::system_clock::now();
     124                 :            : 
     125   [ +  -  -  +  :          1 :   ASSERT_TRUE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
                -  -  - ]
     126         [ +  - ]:          1 :   testRestrictions(properResponse.accelerationRestrictions);
     127                 :            : 
     128                 :          1 :   auto const end = std::chrono::system_clock::now();
     129   [ +  -  +  - ]:          1 :   auto const diff = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
     130                 :            : 
     131                 :            :   // in debug build we should be below 500 ms
     132   [ +  -  -  +  :          1 :   EXPECT_LE(diff.count(), 500);
          -  -  -  -  -  
                      - ]
     133                 :            : }
     134                 :            : 
     135                 :          2 : TEST_F(RssCheckSceneTests, WrongEgoRoadMetricRangeLength)
     136                 :            : {
     137                 :          1 :   state::ProperResponse properResponse;
     138         [ +  - ]:          1 :   core::RssCheck rssCheck;
     139                 :            : 
     140                 :          1 :   worldModel.scenes[0].egoVehicleRoad[0][0].length.minimum = Distance(10);
     141                 :          1 :   worldModel.scenes[0].egoVehicleRoad[0][0].length.maximum = Distance(5);
     142   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
                -  -  - ]
     143                 :            : }
     144                 :            : 
     145                 :          2 : TEST_F(RssCheckSceneTests, WrongEgoRoadMetricRangeWidth)
     146                 :            : {
     147                 :          1 :   state::ProperResponse properResponse;
     148         [ +  - ]:          1 :   core::RssCheck rssCheck;
     149                 :            : 
     150                 :          1 :   worldModel.scenes[0].egoVehicleRoad[0][0].width.minimum = Distance(10);
     151                 :          1 :   worldModel.scenes[0].egoVehicleRoad[0][0].width.maximum = Distance(5);
     152   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
                -  -  - ]
     153                 :            : }
     154                 :            : 
     155                 :            : } // namespace core
     156                 :            : } // namespace rss
     157                 :            : } // namespace ad

Generated by: LCOV version 1.14