LCOV - code coverage report
Current view: top level - tests/structured - RssFormulaTestsCalculateSafeLongitudinalDistanceSameDirection.cpp (source / functions) Hit Total Coverage
Test: ad_rss Lines: 19 19 100.0 %
Date: 2025-07-22 06:53:46 Functions: 9 9 100.0 %
Branches: 21 78 26.9 %

           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 "ad/rss/structured/RssFormulas.hpp"
      11                 :            : 
      12                 :            : namespace ad {
      13                 :            : namespace rss {
      14                 :            : namespace structured {
      15                 :            : 
      16                 :          4 : TEST(RssFormulaTestsCalculateSafeLongitudinalDistanceSameDirection, negative_leading_speed)
      17                 :            : {
      18                 :          1 :   Distance safe_distance(0.);
      19                 :            : 
      20         [ +  - ]:          1 :   core::RelativeObjectState leadingVehicle = createRelativeVehicleStateForLongitudinalMotion(-50);
      21         [ +  - ]:          1 :   core::RelativeObjectState followingVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
      22                 :            : 
      23   [ +  -  -  +  :          1 :   ASSERT_FALSE(calculateSafeLongitudinalDistanceSameDirection(leadingVehicle, followingVehicle, safe_distance));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
      24                 :            : }
      25                 :            : 
      26                 :          4 : TEST(RssFormulaTestsCalculateSafeLongitudinalDistanceSameDirection, checks_leading_vehicle_much_faster)
      27                 :            : {
      28                 :          1 :   Distance safe_distance(0.);
      29         [ +  - ]:          1 :   core::RelativeObjectState leadingVehicle = createRelativeVehicleStateForLongitudinalMotion(100);
      30         [ +  - ]:          1 :   core::RelativeObjectState followingVehicle = createRelativeVehicleStateForLongitudinalMotion(10);
      31                 :            : 
      32   [ +  -  -  +  :          1 :   ASSERT_TRUE(calculateSafeLongitudinalDistanceSameDirection(leadingVehicle, followingVehicle, safe_distance));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
      33                 :            : 
      34   [ +  -  -  +  :          1 :   ASSERT_NEAR(safe_distance.mDistance, 0, cDoubleNear);
          -  -  -  -  -  
                -  +  - ]
      35                 :            : }
      36                 :            : 
      37                 :          4 : TEST(RssFormulaTestsCalculateSafeLongitudinalDistanceSameDirection,
      38                 :            :      checks_leading_vehicle_much_faster_min_safety_distance)
      39                 :            : {
      40                 :          1 :   Distance safe_distance(0.);
      41         [ +  - ]:          1 :   core::RelativeObjectState leadingVehicle = createRelativeVehicleStateForLongitudinalMotion(100);
      42         [ +  - ]:          1 :   core::RelativeObjectState followingVehicle = createRelativeVehicleStateForLongitudinalMotion(10);
      43                 :          1 :   followingVehicle.dynamics.min_longitudinal_safety_distance = physics::Distance(2.);
      44                 :            : 
      45   [ +  -  -  +  :          1 :   ASSERT_TRUE(calculateSafeLongitudinalDistanceSameDirection(leadingVehicle, followingVehicle, safe_distance));
          -  -  -  -  -  
             -  -  -  +  
                      - ]
      46                 :            : 
      47   [ +  -  -  +  :          1 :   ASSERT_NEAR(
          -  -  -  -  -  
                      - ]
      48         [ +  - ]:          1 :     safe_distance.mDistance, followingVehicle.dynamics.min_longitudinal_safety_distance.mDistance, cDoubleNear);
      49                 :            : }
      50                 :            : 
      51                 :            : } // namespace structured
      52                 :            : } // namespace rss
      53                 :            : } // namespace ad

Generated by: LCOV version 1.14