LCOV - code coverage report
Current view: top level - tests/core - RssCheckOppositeDirectionTests.cpp (source / functions) Hit Total Coverage
Test: ad_rss Lines: 77 77 100.0 %
Date: 2024-04-23 14:35:54 Functions: 57 57 100.0 %
Branches: 27 72 37.5 %

           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 "RssCheckTestBaseT.hpp"
      10                 :            : 
      11                 :            : namespace ad {
      12                 :            : namespace rss {
      13                 :            : namespace core {
      14                 :            : 
      15                 :            : template <class TESTBASE> class RssCheckOppositeDirectionEgoCorrectTestBase : public TESTBASE
      16                 :            : {
      17                 :        507 :   situation::SituationType getSituationType() override
      18                 :            :   {
      19                 :        507 :     return situation::SituationType::OppositeDirection;
      20                 :            :   }
      21                 :            : 
      22                 :         54 :   world::Object &getEgoObject() override
      23                 :            :   {
      24                 :         54 :     return TESTBASE::objectOnSegment1;
      25                 :            :   }
      26                 :            : 
      27                 :         54 :   world::Object &getSceneObject(uint32_t) override
      28                 :            :   {
      29                 :         54 :     return TESTBASE::objectOnSegment7;
      30                 :            :   }
      31                 :            : };
      32                 :            : 
      33                 :            : using RssCheckOppositeDirectionEgoCorrectTest = RssCheckOppositeDirectionEgoCorrectTestBase<RssCheckTestBase>;
      34                 :          2 : TEST_F(RssCheckOppositeDirectionEgoCorrectTest, DifferentDistances)
      35                 :            : {
      36                 :          1 :   performDifferentDistancesTest(state::LongitudinalResponse::BrakeMinCorrect);
      37                 :          1 : }
      38                 :            : 
      39                 :          2 : TEST_F(RssCheckOppositeDirectionEgoCorrectTest, DifferentVelocities)
      40                 :            : {
      41                 :          1 :   performDifferentVelocitiesTest(state::LongitudinalResponse::BrakeMinCorrect);
      42                 :          1 : }
      43                 :            : 
      44                 :          2 : TEST_F(RssCheckOppositeDirectionEgoCorrectTest, DifferentVelocities_DifferentLaneSegements)
      45                 :            : {
      46                 :          1 :   worldModel.scenes[0].egoVehicle.occupiedRegions[0].segmentId = 2;
      47                 :          1 :   performDifferentVelocitiesTest(state::LongitudinalResponse::BrakeMinCorrect);
      48                 :          1 : }
      49                 :            : 
      50                 :            : using RssCheckOppositeDirectionEgoCorrectOutOfMemoryTest
      51                 :            :   = RssCheckOppositeDirectionEgoCorrectTestBase<RssCheckOutOfMemoryTestBase>;
      52   [ +  -  +  -  :        101 : TEST_P(RssCheckOppositeDirectionEgoCorrectOutOfMemoryTest, outOfMemoryAnyTime)
          +  -  +  -  +  
                      - ]
      53                 :            : {
      54         [ +  - ]:         50 :   performOutOfMemoryTest();
      55                 :         50 : }
      56   [ -  +  -  -  :         51 : INSTANTIATE_TEST_CASE_P(Range,
                   -  - ]
      57                 :            :                         RssCheckOppositeDirectionEgoCorrectOutOfMemoryTest,
      58                 :            :                         ::testing::Range(uint64_t(0u), uint64_t(50u), 1u));
      59                 :            : 
      60                 :          2 : TEST_F(RssCheckOppositeDirectionEgoCorrectTest, DifferentVelocities_NoLateralConflict)
      61                 :            : {
      62                 :          1 :   worldModel.scenes[0].egoVehicle.occupiedRegions[0].segmentId = 0;
      63                 :          1 :   worldModel.scenes[0].egoVehicle.occupiedRegions[0].latRange.minimum = ParametricValue(0.0);
      64                 :          1 :   worldModel.scenes[0].egoVehicle.occupiedRegions[0].latRange.maximum = ParametricValue(0.1);
      65                 :            : 
      66                 :          1 :   worldModel.scenes[0].object.occupiedRegions[0].segmentId = 8;
      67                 :            : 
      68                 :          1 :   state::ProperResponse properResponse;
      69         [ +  - ]:          1 :   core::RssCheck rssCheck;
      70                 :            : 
      71         [ +  + ]:        101 :   for (uint32_t i = 0; i < 100; i++)
      72                 :            :   {
      73                 :        100 :     worldModel.scenes[0].egoVehicle.velocity.speedLonMin = kmhToMeterPerSec(i);
      74                 :        100 :     worldModel.scenes[0].egoVehicle.velocity.speedLonMax = kmhToMeterPerSec(i);
      75                 :        100 :     worldModel.timeIndex++;
      76                 :            : 
      77   [ +  -  -  +  :        100 :     ASSERT_TRUE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
                -  -  - ]
      78                 :            : 
      79         [ +  - ]:        100 :     testRestrictions(properResponse.accelerationRestrictions);
      80                 :            :   }
      81                 :            : }
      82                 :            : 
      83                 :            : template <class TESTBASE> class RssCheckOppositeDirectionOtherCorrectTestBase : public TESTBASE
      84                 :            : {
      85                 :        450 :   world::LaneDrivingDirection getDrivingDirection() override
      86                 :            :   {
      87                 :        450 :     return world::LaneDrivingDirection::Negative;
      88                 :            :   }
      89                 :            : 
      90                 :        503 :   situation::SituationType getSituationType() override
      91                 :            :   {
      92                 :        503 :     return situation::SituationType::OppositeDirection;
      93                 :            :   }
      94                 :            : 
      95                 :         53 :   world::Object &getEgoObject() override
      96                 :            :   {
      97                 :         53 :     return TESTBASE::objectOnSegment1;
      98                 :            :   }
      99                 :            : 
     100                 :         53 :   world::Object &getSceneObject(uint32_t) override
     101                 :            :   {
     102                 :         53 :     return TESTBASE::objectOnSegment7;
     103                 :            :   }
     104                 :            : };
     105                 :            : 
     106                 :            : using RssCheckOppositeDirectionOtherCorrectTest = RssCheckOppositeDirectionOtherCorrectTestBase<RssCheckTestBase>;
     107                 :          2 : TEST_F(RssCheckOppositeDirectionOtherCorrectTest, DifferentDistances)
     108                 :            : {
     109                 :          1 :   performDifferentDistancesTest(state::LongitudinalResponse::BrakeMin);
     110                 :          1 : }
     111                 :            : 
     112                 :          2 : TEST_F(RssCheckOppositeDirectionOtherCorrectTest, DifferentVelocities)
     113                 :            : {
     114                 :          1 :   performDifferentVelocitiesTest(state::LongitudinalResponse::BrakeMin);
     115                 :          1 : }
     116                 :            : 
     117                 :          2 : TEST_F(RssCheckOppositeDirectionOtherCorrectTest, DifferentVelocities_DifferentLaneSegements)
     118                 :            : {
     119                 :          1 :   worldModel.scenes[0].egoVehicle.occupiedRegions[0].segmentId = 2;
     120                 :          1 :   performDifferentVelocitiesTest(state::LongitudinalResponse::BrakeMin);
     121                 :          1 : }
     122                 :            : 
     123                 :            : using RssCheckOppositeDirectionOtherCorrectOutOfMemoryTest
     124                 :            :   = RssCheckOppositeDirectionOtherCorrectTestBase<RssCheckOutOfMemoryTestBase>;
     125   [ +  -  +  -  :        101 : TEST_P(RssCheckOppositeDirectionOtherCorrectOutOfMemoryTest, outOfMemoryAnyTime)
          +  -  +  -  +  
                      - ]
     126                 :            : {
     127         [ +  - ]:         50 :   performOutOfMemoryTest();
     128                 :         50 : }
     129   [ -  +  -  -  :         51 : INSTANTIATE_TEST_CASE_P(Range,
                   -  - ]
     130                 :            :                         RssCheckOppositeDirectionOtherCorrectOutOfMemoryTest,
     131                 :            :                         ::testing::Range(uint64_t(0u), uint64_t(50u), 1u));
     132                 :            : 
     133                 :            : template <class TESTBASE> class RssCheckOppositeDirectionBothCorrectTestBase : public TESTBASE
     134                 :            : {
     135                 :        450 :   world::LaneDrivingDirection getDrivingDirection() override
     136                 :            :   {
     137                 :        450 :     return world::LaneDrivingDirection::Bidirectional;
     138                 :            :   }
     139                 :            : 
     140                 :        503 :   situation::SituationType getSituationType() override
     141                 :            :   {
     142                 :        503 :     return situation::SituationType::OppositeDirection;
     143                 :            :   }
     144                 :            : 
     145                 :         53 :   world::Object &getEgoObject() override
     146                 :            :   {
     147                 :         53 :     return TESTBASE::objectOnSegment1;
     148                 :            :   }
     149                 :            : 
     150                 :         53 :   world::Object &getSceneObject(uint32_t) override
     151                 :            :   {
     152                 :         53 :     return TESTBASE::objectOnSegment7;
     153                 :            :   }
     154                 :            : };
     155                 :            : 
     156                 :            : using RssCheckOppositeDirectionBothCorrectTest = RssCheckOppositeDirectionBothCorrectTestBase<RssCheckTestBase>;
     157                 :          2 : TEST_F(RssCheckOppositeDirectionBothCorrectTest, DifferentDistances)
     158                 :            : {
     159                 :          1 :   performDifferentDistancesTest(state::LongitudinalResponse::BrakeMinCorrect);
     160                 :          1 : }
     161                 :            : 
     162                 :          2 : TEST_F(RssCheckOppositeDirectionBothCorrectTest, DifferentVelocities)
     163                 :            : {
     164                 :          1 :   performDifferentVelocitiesTest(state::LongitudinalResponse::BrakeMinCorrect);
     165                 :          1 : }
     166                 :            : 
     167                 :          2 : TEST_F(RssCheckOppositeDirectionBothCorrectTest, DifferentVelocities_DifferentLaneSegements)
     168                 :            : {
     169                 :          1 :   worldModel.scenes[0].egoVehicle.occupiedRegions[0].segmentId = 2;
     170                 :          1 :   performDifferentVelocitiesTest(state::LongitudinalResponse::BrakeMinCorrect);
     171                 :          1 : }
     172                 :            : 
     173                 :            : using RssCheckOppositeDirectionBothCorrectOutOfMemoryTest
     174                 :            :   = RssCheckOppositeDirectionBothCorrectTestBase<RssCheckOutOfMemoryTestBase>;
     175   [ +  -  +  -  :        101 : TEST_P(RssCheckOppositeDirectionBothCorrectOutOfMemoryTest, outOfMemoryAnyTime)
          +  -  +  -  +  
                      - ]
     176                 :            : {
     177         [ +  - ]:         50 :   performOutOfMemoryTest();
     178                 :         50 : }
     179   [ -  +  -  -  :         51 : INSTANTIATE_TEST_CASE_P(Range,
                   -  - ]
     180                 :            :                         RssCheckOppositeDirectionBothCorrectOutOfMemoryTest,
     181                 :            :                         ::testing::Range(uint64_t(0u), uint64_t(50u), 1u));
     182                 :            : 
     183                 :            : } // namespace core
     184                 :            : } // namespace rss
     185                 :            : } // namespace ad

Generated by: LCOV version 1.14