LCOV - code coverage report
Current view: top level - tests/situation - RssSituationCheckingTestsIntersectionInputRangeTests.cpp (source / functions) Hit Total Coverage
Test: ad_rss Lines: 67 67 100.0 %
Date: 2024-04-30 13:12:49 Functions: 10 10 100.0 %
Branches: 10 36 27.8 %

           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 "TestSupport.hpp"
      10                 :            : #include "situation/RssStructuredSceneIntersectionChecker.hpp"
      11                 :            : 
      12                 :            : namespace ad {
      13                 :            : namespace rss {
      14                 :            : namespace situation {
      15                 :            : 
      16                 :            : class RssSituationCheckingTestsIntersectionInputRangeTests : public testing::Test
      17                 :            : {
      18                 :            : protected:
      19                 :          4 :   virtual void SetUp()
      20                 :            :   {
      21                 :          4 :     situation.situationType = SituationType::IntersectionEgoHasPriority;
      22                 :          4 :   }
      23                 :            : 
      24                 :          3 :   void performTestRun()
      25                 :            :   {
      26                 :          6 :     RssStructuredSceneIntersectionChecker checker;
      27   [ +  -  -  +  :          3 :     EXPECT_FALSE(checker.calculateRssStateIntersection(timeIndex++, situation, rssState));
          -  -  -  -  -  
                -  -  - ]
      28                 :          3 :   }
      29                 :            :   VehicleState leadingVehicle;
      30                 :            :   VehicleState followingVehicle;
      31                 :            :   Situation situation;
      32                 :            :   state::RssState rssState;
      33                 :            :   world::TimeIndex timeIndex{1u};
      34                 :            : };
      35                 :            : 
      36                 :          2 : TEST_F(RssSituationCheckingTestsIntersectionInputRangeTests, no_priority_vehicle)
      37                 :            : {
      38                 :          1 :   RssStructuredSceneIntersectionChecker checker;
      39         [ +  - ]:          1 :   leadingVehicle = createVehicleStateForLongitudinalMotion(50);
      40                 :          1 :   leadingVehicle.distanceToEnterIntersection = Distance(10.);
      41                 :          1 :   leadingVehicle.distanceToLeaveIntersection = Distance(10.);
      42         [ +  - ]:          1 :   followingVehicle = createVehicleStateForLongitudinalMotion(50);
      43                 :          1 :   followingVehicle.dynamics.alphaLon.accelMax = Acceleration(2.);
      44                 :          1 :   followingVehicle.dynamics.alphaLon.brakeMin = Acceleration(-4.);
      45                 :          1 :   followingVehicle.distanceToEnterIntersection = Distance(70.);
      46                 :          1 :   followingVehicle.distanceToLeaveIntersection = Distance(70.);
      47                 :            : 
      48                 :          1 :   situation.egoVehicleState = leadingVehicle;
      49                 :          1 :   situation.otherVehicleState = followingVehicle;
      50         [ +  - ]:          1 :   situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::InFront, Distance(60.));
      51                 :            : 
      52   [ +  -  -  +  :          1 :   ASSERT_TRUE(checker.calculateRssStateIntersection(timeIndex++, situation, rssState));
          -  -  -  -  -  
                -  -  - ]
      53                 :            : }
      54                 :            : 
      55                 :          2 : TEST_F(RssSituationCheckingTestsIntersectionInputRangeTests, distanceToLeaveSmallerEgo)
      56                 :            : {
      57                 :          1 :   situation.egoVehicleState = createVehicleStateForLongitudinalMotion(120);
      58                 :          1 :   situation.egoVehicleState.distanceToEnterIntersection = Distance(15.);
      59                 :          1 :   situation.egoVehicleState.distanceToLeaveIntersection = Distance(14.);
      60                 :            : 
      61                 :          1 :   situation.egoVehicleState.dynamics.alphaLon.accelMax = Acceleration(2.);
      62                 :          1 :   situation.egoVehicleState.dynamics.alphaLon.brakeMin = Acceleration(-4.);
      63                 :            : 
      64                 :          1 :   situation.otherVehicleState = createVehicleStateForLongitudinalMotion(10);
      65                 :          1 :   situation.otherVehicleState.dynamics.alphaLon.accelMax = Acceleration(2.);
      66                 :          1 :   situation.otherVehicleState.dynamics.alphaLon.brakeMin = Acceleration(-4.);
      67                 :          1 :   situation.otherVehicleState.distanceToEnterIntersection = Distance(16.);
      68                 :          1 :   situation.otherVehicleState.distanceToLeaveIntersection = Distance(16.);
      69                 :          1 :   situation.otherVehicleState.hasPriority = true;
      70                 :            : 
      71         [ +  - ]:          1 :   situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::AtBack, Distance(1.));
      72                 :            : 
      73                 :          1 :   performTestRun();
      74                 :          1 : }
      75                 :            : 
      76                 :          2 : TEST_F(RssSituationCheckingTestsIntersectionInputRangeTests, distanceToLeaveSmallerOther)
      77                 :            : {
      78                 :          1 :   situation.egoVehicleState = createVehicleStateForLongitudinalMotion(120);
      79                 :          1 :   situation.egoVehicleState.distanceToEnterIntersection = Distance(15.);
      80                 :          1 :   situation.egoVehicleState.distanceToLeaveIntersection = Distance(15.);
      81                 :            : 
      82                 :          1 :   situation.egoVehicleState.dynamics.alphaLon.accelMax = Acceleration(2.);
      83                 :          1 :   situation.egoVehicleState.dynamics.alphaLon.brakeMin = Acceleration(-4.);
      84                 :            : 
      85                 :          1 :   situation.otherVehicleState = createVehicleStateForLongitudinalMotion(10);
      86                 :          1 :   situation.otherVehicleState.dynamics.alphaLon.accelMax = Acceleration(2.);
      87                 :          1 :   situation.otherVehicleState.dynamics.alphaLon.brakeMin = Acceleration(-4.);
      88                 :          1 :   situation.otherVehicleState.distanceToEnterIntersection = Distance(16.);
      89                 :          1 :   situation.otherVehicleState.distanceToLeaveIntersection = Distance(15.);
      90                 :          1 :   situation.otherVehicleState.hasPriority = true;
      91                 :            : 
      92         [ +  - ]:          1 :   situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::AtBack, Distance(1.));
      93                 :            : 
      94                 :          1 :   performTestRun();
      95                 :          1 : }
      96                 :            : 
      97                 :          2 : TEST_F(RssSituationCheckingTestsIntersectionInputRangeTests, both_priority_vehicle)
      98                 :            : {
      99                 :          1 :   leadingVehicle = createVehicleStateForLongitudinalMotion(50);
     100                 :          1 :   leadingVehicle.distanceToEnterIntersection = Distance(10.);
     101                 :          1 :   leadingVehicle.distanceToLeaveIntersection = Distance(10.);
     102                 :          1 :   leadingVehicle.hasPriority = true;
     103                 :            : 
     104                 :          1 :   followingVehicle = createVehicleStateForLongitudinalMotion(50);
     105                 :          1 :   followingVehicle.dynamics.alphaLon.accelMax = Acceleration(2.);
     106                 :          1 :   followingVehicle.dynamics.alphaLon.brakeMin = Acceleration(-4.);
     107                 :          1 :   followingVehicle.distanceToEnterIntersection = Distance(70.);
     108                 :          1 :   leadingVehicle.distanceToLeaveIntersection = Distance(70.);
     109                 :          1 :   followingVehicle.hasPriority = true;
     110                 :            : 
     111                 :          1 :   situation.egoVehicleState = leadingVehicle;
     112                 :          1 :   situation.otherVehicleState = followingVehicle;
     113         [ +  - ]:          1 :   situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::InFront, Distance(60.));
     114                 :            : 
     115                 :          1 :   performTestRun();
     116                 :          1 : }
     117                 :            : 
     118                 :            : } // namespace situation
     119                 :            : } // namespace rss
     120                 :            : } // namespace ad

Generated by: LCOV version 1.14