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(RssFormulaTestsInputRangeChecks, checkSafeLongitudinalDistanceSameDirection)
17 : : {
18 : 1 : bool is_safe = false;
19 : 1 : Distance vehicleDistance(-1.);
20 : 1 : Distance safe_distance(0);
21 [ + - ]: 1 : core::RelativeObjectState leadingVehicle = createRelativeVehicleStateForLongitudinalMotion(10);
22 [ + - ]: 1 : core::RelativeObjectState followingVehicle = createRelativeVehicleStateForLongitudinalMotion(10);
23 : :
24 [ + - - + : 1 : ASSERT_FALSE(checkSafeLongitudinalDistanceSameDirection(
- - - - -
- - - ]
25 [ + - ]: 1 : leadingVehicle, followingVehicle, vehicleDistance, safe_distance, is_safe));
26 : : }
27 : :
28 : 4 : TEST(RssFormulaTestsInputRangeChecks, checkSafeLongitudinalDistanceOppositeDirection)
29 : : {
30 : 1 : bool is_safe = false;
31 : 1 : Distance vehicleDistance(-1.);
32 : 1 : Distance safe_distance(0);
33 [ + - ]: 1 : core::RelativeObjectState correctVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
34 [ + - ]: 1 : core::RelativeObjectState oppositeVehicle = createRelativeVehicleStateForLongitudinalMotion(-50);
35 : :
36 [ + - - + : 1 : ASSERT_FALSE(checkSafeLongitudinalDistanceOppositeDirection(
- - - - -
- - - ]
37 [ + - ]: 1 : correctVehicle, oppositeVehicle, vehicleDistance, safe_distance, is_safe));
38 : : }
39 : :
40 : 4 : TEST(RssFormulaTestsInputRangeChecks, checkSafeLateralDistance)
41 : : {
42 : 1 : bool is_safe = false;
43 : 1 : Distance vehicleDistance(-1.);
44 : 1 : Distance safe_distance(0);
45 [ + - ]: 1 : core::RelativeObjectState leftVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
46 [ + - ]: 1 : core::RelativeObjectState rightVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
47 : :
48 [ + - - + : 1 : ASSERT_FALSE(checkSafeLateralDistance(leftVehicle, rightVehicle, vehicleDistance, safe_distance, is_safe));
- - - - -
- - - +
- ]
49 : : }
50 : :
51 : 4 : TEST(RssFormulaTestsInputRangeChecks, calculateSafeLongitudinalDistanceOppositeDirection)
52 : : {
53 : 1 : Distance safe_distance(0.);
54 : :
55 [ + - ]: 1 : core::RelativeObjectState correctVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
56 [ + - ]: 1 : core::RelativeObjectState oppositeVehicle = createRelativeVehicleStateForLongitudinalMotion(-50);
57 : 1 : correctVehicle.dynamics.response_time = Duration(-1);
58 [ + - - + : 1 : ASSERT_FALSE(calculateSafeLongitudinalDistanceOppositeDirection(correctVehicle, oppositeVehicle, safe_distance));
- - - - -
- - - +
- ]
59 [ + - - + : 1 : ASSERT_FALSE(calculateSafeLongitudinalDistanceOppositeDirection(oppositeVehicle, correctVehicle, safe_distance));
- - - - -
- - - +
- ]
60 : : }
61 : :
62 : 4 : TEST(RssFormulaTestsInputRangeChecks, checkStopInFrontIntersection)
63 : : {
64 : 1 : bool is_safe = false;
65 : 1 : Distance safe_distance(0.);
66 [ + - ]: 1 : core::RelativeObjectState correctVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
67 : 1 : correctVehicle.dynamics.response_time = Duration(-1);
68 [ + - - + : 1 : ASSERT_FALSE(checkStopInFrontIntersection(correctVehicle, safe_distance, is_safe));
- - - - -
- - - +
- ]
69 : : }
70 : :
71 : : } // namespace structured
72 : : } // namespace rss
73 : : } // namespace ad
|