LCOV - code coverage report
Current view: top level - tests/core - RssCheckObjectTests.cpp (source / functions) Hit Total Coverage
Test: ad_rss Lines: 132 132 100.0 %
Date: 2025-07-09 09:45:10 Functions: 54 54 100.0 %
Branches: 142 424 33.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                 :            : class RssCheckObjectTests : public RssCheckTestBaseT<testing::Test>
      16                 :            : {
      17                 :            : };
      18                 :            : 
      19                 :          4 : TEST_F(RssCheckObjectTests, validateTestSetup)
      20                 :            : {
      21                 :          1 :   state::ProperResponse properResponse;
      22         [ +  - ]:          1 :   core::RssCheck rssCheck;
      23                 :            : 
      24   [ +  -  -  +  :          1 :   ASSERT_TRUE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
      25         [ +  - ]:          1 :   testRestrictions(properResponse.acceleration_restrictions);
      26   [ +  -  +  - ]:          1 : }
      27                 :            : 
      28                 :          4 : TEST_F(RssCheckObjectTests, HugeEgoObjectId)
      29                 :            : {
      30                 :          1 :   state::ProperResponse properResponse;
      31         [ +  - ]:          1 :   core::RssCheck rssCheck;
      32                 :            : 
      33                 :          1 :   worldModel.constellations[0].ego_vehicle.object_id = std::numeric_limits<uint64_t>::max();
      34                 :            : 
      35   [ +  -  -  +  :          1 :   ASSERT_TRUE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
      36         [ +  - ]:          1 :   testRestrictions(properResponse.acceleration_restrictions);
      37   [ +  -  +  - ]:          1 : }
      38                 :            : 
      39                 :          4 : TEST_F(RssCheckObjectTests, HugeOtherObjectId)
      40                 :            : {
      41                 :          1 :   state::ProperResponse properResponse;
      42         [ +  - ]:          1 :   core::RssCheck rssCheck;
      43                 :            : 
      44                 :          1 :   worldModel.constellations[0].object.object_id = std::numeric_limits<uint64_t>::max();
      45                 :            : 
      46   [ +  -  -  +  :          1 :   ASSERT_TRUE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
      47         [ +  - ]:          1 :   testRestrictions(properResponse.acceleration_restrictions);
      48   [ +  -  +  - ]:          1 : }
      49                 :            : 
      50                 :          4 : TEST_F(RssCheckObjectTests, SameObjectId)
      51                 :            : {
      52                 :          1 :   state::ProperResponse properResponse;
      53         [ +  - ]:          1 :   core::RssCheck rssCheck;
      54                 :            : 
      55                 :          1 :   worldModel.constellations[0].object.object_id = worldModel.constellations[0].ego_vehicle.object_id;
      56                 :            : 
      57   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
      58   [ +  -  +  - ]:          1 : }
      59                 :            : 
      60                 :          4 : TEST_F(RssCheckObjectTests, ZeroObjectId)
      61                 :            : {
      62                 :          1 :   state::ProperResponse properResponse;
      63         [ +  - ]:          1 :   core::RssCheck rssCheck;
      64                 :            : 
      65                 :          1 :   worldModel.constellations[0].object.object_id = std::numeric_limits<uint64_t>::max() + 1;
      66                 :            : 
      67   [ +  -  -  +  :          1 :   ASSERT_TRUE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
      68         [ +  - ]:          1 :   testRestrictions(properResponse.acceleration_restrictions);
      69   [ +  -  +  - ]:          1 : }
      70                 :            : 
      71                 :          4 : TEST_F(RssCheckObjectTests, EgoObjectTypeValidity)
      72                 :            : {
      73                 :          1 :   state::ProperResponse properResponse;
      74         [ +  - ]:          1 :   core::RssCheck rssCheck;
      75                 :            : 
      76         [ +  + ]:         11 :   for (int32_t i = 0; i < 10; ++i)
      77                 :            :   {
      78                 :         10 :     worldModel.time_index++;
      79                 :         10 :     worldModel.constellations[0].ego_vehicle.object_type = static_cast<world::ObjectType>(i);
      80         [ +  + ]:         10 :     if (worldModel.constellations[0].ego_vehicle.object_type == world::ObjectType::EgoVehicle)
      81                 :            :     {
      82   [ +  -  -  +  :          1 :       ASSERT_TRUE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
      83         [ +  - ]:          1 :       testRestrictions(properResponse.acceleration_restrictions);
      84                 :            :     }
      85                 :            :     else
      86                 :            :     {
      87   [ +  -  -  +  :          9 :       ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
      88                 :            :     }
      89                 :            :   }
      90   [ +  -  +  - ]:          1 : }
      91                 :            : 
      92                 :          4 : TEST_F(RssCheckObjectTests, ObjectObjectTypeValidity)
      93                 :            : {
      94                 :          1 :   state::ProperResponse properResponse;
      95         [ +  - ]:          1 :   core::RssCheck rssCheck;
      96                 :            : 
      97         [ +  + ]:         11 :   for (int32_t i = 0; i < 10; ++i)
      98                 :            :   {
      99                 :         10 :     worldModel.time_index++;
     100                 :         10 :     worldModel.constellations[0].object.object_type = static_cast<world::ObjectType>(i);
     101                 :         10 :     if ((worldModel.constellations[0].object.object_type == world::ObjectType::ArtificialObject)
     102         [ +  + ]:          9 :         || (worldModel.constellations[0].object.object_type == world::ObjectType::ArtificialPedestrian)
     103         [ +  + ]:          8 :         || (worldModel.constellations[0].object.object_type == world::ObjectType::ArtificialVehicle)
     104         [ +  + ]:          7 :         || (worldModel.constellations[0].object.object_type == world::ObjectType::OtherVehicle)
     105         [ +  + ]:          6 :         || (worldModel.constellations[0].object.object_type == world::ObjectType::Pedestrian)
     106         [ +  + ]:          5 :         || (worldModel.constellations[0].object.object_type == world::ObjectType::Bicycle)
     107   [ +  +  +  +  :         19 :         || (worldModel.constellations[0].object.object_type == world::ObjectType::OtherObject))
                   +  + ]
     108                 :            :     {
     109   [ +  -  -  +  :          7 :       ASSERT_TRUE(rssCheck.calculateProperResponse(worldModel, properResponse)) << i;
          -  -  -  -  -  
          -  -  -  -  -  
                   +  - ]
     110         [ +  - ]:          7 :       testRestrictions(properResponse.acceleration_restrictions);
     111                 :            :     }
     112                 :            :     else
     113                 :            :     {
     114   [ +  -  -  +  :          3 :       ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
     115                 :            :     }
     116                 :            :   }
     117   [ +  -  +  - ]:          1 : }
     118                 :            : 
     119                 :          4 : TEST_F(RssCheckObjectTests, HugeEgoVelocity)
     120                 :            : {
     121                 :          1 :   state::ProperResponse properResponse;
     122         [ +  - ]:          1 :   core::RssCheck rssCheck;
     123                 :            : 
     124                 :          1 :   worldModel.constellations[0].ego_vehicle.velocity.speed_lon_min = Speed(100);
     125                 :          1 :   worldModel.constellations[0].ego_vehicle.velocity.speed_lon_max = Speed(300);
     126                 :            : 
     127   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
     128   [ +  -  +  - ]:          1 : }
     129                 :            : 
     130                 :          4 : TEST_F(RssCheckObjectTests, HugeEgoAcceleration)
     131                 :            : {
     132                 :          1 :   state::ProperResponse properResponse;
     133         [ +  - ]:          1 :   core::RssCheck rssCheck;
     134                 :            : 
     135                 :          1 :   worldModel.default_ego_vehicle_rss_dynamics.alpha_lon.accel_max = Acceleration(120);
     136                 :            : 
     137   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
     138   [ +  -  +  - ]:          1 : }
     139                 :            : 
     140                 :          4 : TEST_F(RssCheckObjectTests, EmptyEgoVehicleOccupiedRegion)
     141                 :            : {
     142                 :          1 :   state::ProperResponse properResponse;
     143         [ +  - ]:          1 :   core::RssCheck rssCheck;
     144                 :            : 
     145                 :          1 :   worldModel.constellations[0].ego_vehicle.occupied_regions.clear();
     146                 :            : 
     147   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
     148   [ +  -  +  - ]:          1 : }
     149                 :            : 
     150                 :          4 : TEST_F(RssCheckObjectTests, WrongEgoVehicleOccupiedRegion)
     151                 :            : {
     152                 :          1 :   state::ProperResponse properResponse;
     153         [ +  - ]:          1 :   core::RssCheck rssCheck;
     154                 :            : 
     155                 :          1 :   worldModel.constellations[0].ego_vehicle.occupied_regions[0].lon_range.minimum = ParametricValue(0.5);
     156                 :          1 :   worldModel.constellations[0].ego_vehicle.occupied_regions[0].lon_range.maximum = ParametricValue(0.3);
     157                 :            : 
     158   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
     159   [ +  -  +  - ]:          1 : }
     160                 :            : 
     161                 :          4 : TEST_F(RssCheckObjectTests, NegativeEgoVehicleLongitudinalAcceleration)
     162                 :            : {
     163                 :          1 :   state::ProperResponse properResponse;
     164         [ +  - ]:          1 :   core::RssCheck rssCheck;
     165                 :            : 
     166                 :          1 :   worldModel.default_ego_vehicle_rss_dynamics.alpha_lon.accel_max = Acceleration(-3);
     167                 :            : 
     168   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
     169   [ +  -  +  - ]:          1 : }
     170                 :            : 
     171                 :          4 : TEST_F(RssCheckObjectTests, IncorrectEgoVehicleLongitudinalAccelerationRange)
     172                 :            : {
     173                 :          1 :   state::ProperResponse properResponse;
     174         [ +  - ]:          1 :   core::RssCheck rssCheck;
     175                 :            : 
     176                 :          1 :   worldModel.default_ego_vehicle_rss_dynamics.alpha_lon.brake_max = Acceleration(-1);
     177                 :          1 :   worldModel.default_ego_vehicle_rss_dynamics.alpha_lon.brake_min = Acceleration(-5);
     178                 :            : 
     179   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
     180   [ +  -  +  - ]:          1 : }
     181                 :            : 
     182                 :          4 : TEST_F(RssCheckObjectTests, IncorrectEgoVehicleLongitudinalAccelerationRange2)
     183                 :            : {
     184                 :          1 :   state::ProperResponse properResponse;
     185         [ +  - ]:          1 :   core::RssCheck rssCheck;
     186                 :            : 
     187                 :          1 :   worldModel.default_ego_vehicle_rss_dynamics.alpha_lon.brake_min = Acceleration(-1);
     188                 :          1 :   worldModel.default_ego_vehicle_rss_dynamics.alpha_lon.brake_min_correct = Acceleration(-5);
     189                 :            : 
     190   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
     191   [ +  -  +  - ]:          1 : }
     192                 :            : 
     193                 :          4 : TEST_F(RssCheckObjectTests, PositiveEgoVehicleLateralAcceleration)
     194                 :            : {
     195                 :          1 :   state::ProperResponse properResponse;
     196         [ +  - ]:          1 :   core::RssCheck rssCheck;
     197                 :            : 
     198                 :          1 :   worldModel.default_ego_vehicle_rss_dynamics.alpha_lat.brake_min = Acceleration(1);
     199                 :            : 
     200   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
     201   [ +  -  +  - ]:          1 : }
     202                 :            : 
     203                 :          4 : TEST_F(RssCheckObjectTests, NegativeEgoVehicleLongitudinalVelocity)
     204                 :            : {
     205                 :          1 :   state::ProperResponse properResponse;
     206         [ +  - ]:          1 :   core::RssCheck rssCheck;
     207                 :            : 
     208                 :          1 :   worldModel.constellations[0].ego_vehicle.velocity.speed_lon_min = Speed(-3.);
     209                 :          1 :   worldModel.constellations[0].ego_vehicle.velocity.speed_lon_max = Speed(0.);
     210                 :            : 
     211   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
     212   [ +  -  +  - ]:          1 : }
     213                 :            : 
     214                 :          4 : TEST_F(RssCheckObjectTests, NegativeEgoVehicleResponseTime)
     215                 :            : {
     216                 :          1 :   state::ProperResponse properResponse;
     217         [ +  - ]:          1 :   core::RssCheck rssCheck;
     218                 :            : 
     219                 :          1 :   worldModel.default_ego_vehicle_rss_dynamics.response_time = Duration(-5.);
     220                 :            : 
     221   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
     222   [ +  -  +  - ]:          1 : }
     223                 :            : 
     224                 :          4 : TEST_F(RssCheckObjectTests, ZeroEgoVehicleResponseTime)
     225                 :            : {
     226                 :          1 :   state::ProperResponse properResponse;
     227         [ +  - ]:          1 :   core::RssCheck rssCheck;
     228                 :            : 
     229                 :          1 :   worldModel.default_ego_vehicle_rss_dynamics.response_time = Duration(0);
     230                 :            : 
     231   [ +  -  -  +  :          1 :   ASSERT_FALSE(rssCheck.calculateProperResponse(worldModel, properResponse));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
     232   [ +  -  +  - ]:          1 : }
     233                 :            : 
     234                 :            : } // namespace core
     235                 :            : } // namespace rss
     236                 :            : } // namespace ad

Generated by: LCOV version 1.14