LCOV - code coverage report
Current view: top level - tests/situation - PhysicsUnitTestsCalculateTimeToStop.cpp (source / functions) Hit Total Coverage
Test: ad_rss Lines: 28 28 100.0 %
Date: 2024-04-30 13:12:49 Functions: 14 14 100.0 %
Branches: 28 154 18.2 %

           Branch data     Line data    Source code
       1                 :            : 
       2                 :            : // ----------------- BEGIN LICENSE BLOCK ---------------------------------
       3                 :            : //
       4                 :            : // Copyright (C) 2018-2021 Intel Corporation
       5                 :            : //
       6                 :            : // SPDX-License-Identifier: LGPL-2.1-only
       7                 :            : //
       8                 :            : // ----------------- END LICENSE BLOCK -----------------------------------
       9                 :            : 
      10                 :            : #include "TestSupport.hpp"
      11                 :            : #include "ad/rss/situation/Physics.hpp"
      12                 :            : 
      13                 :            : namespace ad {
      14                 :            : namespace rss {
      15                 :            : namespace situation {
      16                 :            : 
      17                 :          2 : TEST(PhysicsUnitTestsCalculateTimeToStop, maxTimeToStopInitialSpeedZero)
      18                 :            : {
      19                 :          1 :   Duration result;
      20   [ +  -  -  +  :          1 :   ASSERT_TRUE(calculateTimeToStop(Speed(0.),          // initialSpeed
          -  -  -  -  -  
                -  -  - ]
      21                 :            :                                   Duration(1.0),      // responseTime
      22                 :            :                                   Speed(4.0),         // maxSpeedOnAcceleration
      23                 :            :                                   Acceleration(2.0),  // aUntilResponseTimeMax
      24                 :            :                                   Acceleration(-2.0), // aAfterResponseTime
      25                 :            :                                   result));
      26   [ +  -  -  +  :          1 :   ASSERT_EQ(result, Duration(2.0));
          -  -  -  -  -  
                      - ]
      27                 :            : }
      28                 :            : 
      29                 :          2 : TEST(PhysicsUnitTestsCalculateTimeToStop, maxTimeToStopInitialSpeedZeroDeceleration)
      30                 :            : {
      31                 :          1 :   Duration result;
      32   [ +  -  -  +  :          1 :   ASSERT_FALSE(calculateTimeToStop(Speed(0.),          // initialSpeed
          -  -  -  -  -  
                -  -  - ]
      33                 :            :                                    Duration(1.0),      // responseTime
      34                 :            :                                    Speed(4.0),         // maxSpeedOnAcceleration
      35                 :            :                                    Acceleration(-2.0), // aUntilResponseTimeMax
      36                 :            :                                    Acceleration(-2.0), // aAfterResponseTime
      37                 :            :                                    result));
      38   [ +  -  -  +  :          1 :   ASSERT_EQ(result, Duration(0.0));
          -  -  -  -  -  
                      - ]
      39                 :            : }
      40                 :            : 
      41                 :          2 : TEST(PhysicsUnitTestsCalculateTimeToStop, maxTimeToStopInitialSpeedDeceleration)
      42                 :            : {
      43                 :          1 :   Duration result;
      44   [ +  -  -  +  :          1 :   ASSERT_TRUE(calculateTimeToStop(Speed(2.),          // initialSpeed
          -  -  -  -  -  
                -  -  - ]
      45                 :            :                                   Duration(1.0),      // responseTime
      46                 :            :                                   Speed(4.0),         // maxSpeedOnAcceleration
      47                 :            :                                   Acceleration(-1.0), // aUntilResponseTimeMax
      48                 :            :                                   Acceleration(-2.0), // aAfterResponseTime
      49                 :            :                                   result));
      50   [ +  -  -  +  :          1 :   ASSERT_EQ(result, Duration(1.5));
          -  -  -  -  -  
                      - ]
      51                 :            : }
      52                 :            : 
      53                 :          2 : TEST(PhysicsUnitTestsCalculateTimeToStop, maxTimeToStopInitialSpeedAccelZero)
      54                 :            : {
      55                 :          1 :   Duration result;
      56   [ +  -  -  +  :          1 :   ASSERT_TRUE(calculateTimeToStop(Speed(2.),          // initialSpeed
          -  -  -  -  -  
                -  -  - ]
      57                 :            :                                   Duration(1.0),      // responseTime
      58                 :            :                                   Speed(4.0),         // maxSpeedOnAcceleration
      59                 :            :                                   Acceleration(0.0),  // aUntilResponseTimeMax
      60                 :            :                                   Acceleration(-2.0), // aAfterResponseTime
      61                 :            :                                   result));
      62   [ +  -  -  +  :          1 :   ASSERT_EQ(result, Duration(2.0));
          -  -  -  -  -  
                      - ]
      63                 :            : }
      64                 :            : 
      65                 :          2 : TEST(PhysicsUnitTestsCalculateTimeToStop, maxTimeToStopInitialSpeedAccelZeroZero)
      66                 :            : {
      67                 :          1 :   Duration result;
      68   [ +  -  -  +  :          1 :   ASSERT_FALSE(calculateTimeToStop(Speed(2.),         // initialSpeed
          -  -  -  -  -  
                -  -  - ]
      69                 :            :                                    Duration(1.0),     // responseTime
      70                 :            :                                    Speed(4.0),        // maxSpeedOnAcceleration
      71                 :            :                                    Acceleration(0.0), // aUntilResponseTimeMax
      72                 :            :                                    Acceleration(0.0), // aAfterResponseTime
      73                 :            :                                    result));
      74   [ +  -  -  +  :          1 :   ASSERT_EQ(result, Duration(0.0));
          -  -  -  -  -  
                      - ]
      75                 :            : }
      76                 :            : 
      77                 :          2 : TEST(PhysicsUnitTestsCalculateTimeToStop, maxTimeToStopInitialSpeedStopBeforeResponseTime)
      78                 :            : {
      79                 :          1 :   Duration result;
      80   [ +  -  -  +  :          1 :   ASSERT_TRUE(calculateTimeToStop(Speed(2.),          // initialSpeed
          -  -  -  -  -  
                -  -  - ]
      81                 :            :                                   Duration(1.0),      // responseTime
      82                 :            :                                   Speed(4.0),         // maxSpeedOnAcceleration
      83                 :            :                                   Acceleration(-4.0), // aUntilResponseTimeMax
      84                 :            :                                   Acceleration(0.0),  // aAfterResponseTime
      85                 :            :                                   result));
      86   [ +  -  -  +  :          1 :   ASSERT_EQ(result, Duration(0.5));
          -  -  -  -  -  
                      - ]
      87                 :            : }
      88                 :            : 
      89                 :          2 : TEST(PhysicsUnitTestsCalculateTimeToStop, maxTimeToStopMaxSpeedOnAccelerationReachedInResponseTime)
      90                 :            : {
      91                 :          1 :   Duration result;
      92   [ +  -  -  +  :          1 :   ASSERT_TRUE(calculateTimeToStop(Speed(2.),          // initialSpeed
          -  -  -  -  -  
                -  -  - ]
      93                 :            :                                   Duration(1.0),      // responseTime
      94                 :            :                                   Speed(4.0),         // maxSpeedOnAcceleration
      95                 :            :                                   Acceleration(4.0),  // aUntilResponseTimeMax
      96                 :            :                                   Acceleration(-2.0), // aAfterResponseTime
      97                 :            :                                   result));
      98   [ +  -  -  +  :          1 :   ASSERT_EQ(result, Duration(3.0));
          -  -  -  -  -  
                      - ]
      99                 :            : }
     100                 :            : 
     101                 :            : } // namespace situation
     102                 :            : } // namespace rss
     103                 :            : } // namespace ad

Generated by: LCOV version 1.14