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 : : 11 : : /* 12 : : * Generated file 13 : : */ 14 : : 15 : : #if defined(__clang__) && (__clang_major__ >= 7) 16 : : #pragma GCC diagnostic push 17 : : #pragma GCC diagnostic ignored "-Wself-assign-overloaded" 18 : : #endif 19 : : 20 : : #include <gtest/gtest.h> 21 : : #include <limits> 22 : : #include "ad/rss/world/RssDynamics.hpp" 23 : : 24 : : class RssDynamicsTests : public testing::Test 25 : : { 26 : : protected: 27 : 12 : virtual void SetUp() override 28 : : { 29 : : // valid initialization 30 : 12 : ::ad::rss::world::RssDynamics value; 31 : 12 : ::ad::rss::world::LongitudinalRssAccelerationValues valueAlphaLon; 32 : 12 : ::ad::physics::Acceleration valueAlphaLonAccelMax(-1e2); 33 : 12 : valueAlphaLonAccelMax = ::ad::physics::Acceleration(0.); // set to valid value within struct 34 : 12 : valueAlphaLon.accelMax = valueAlphaLonAccelMax; 35 : 12 : ::ad::physics::Acceleration valueAlphaLonBrakeMax(-1e2); 36 : 12 : valueAlphaLon.brakeMax = valueAlphaLonBrakeMax; 37 : 12 : ::ad::physics::Acceleration valueAlphaLonBrakeMin(-1e2); 38 : 12 : valueAlphaLon.brakeMin = valueAlphaLonBrakeMin; 39 : 12 : ::ad::physics::Acceleration valueAlphaLonBrakeMinCorrect(-1e2); 40 : 12 : valueAlphaLon.brakeMinCorrect = valueAlphaLonBrakeMinCorrect; 41 : 12 : valueAlphaLon.brakeMin = valueAlphaLon.brakeMax; 42 : 12 : valueAlphaLon.brakeMinCorrect = valueAlphaLon.brakeMin; 43 : 12 : valueAlphaLon.brakeMin = valueAlphaLon.brakeMinCorrect; 44 : 12 : valueAlphaLon.brakeMax = valueAlphaLon.brakeMin; 45 : 12 : value.alphaLon = valueAlphaLon; 46 : 12 : ::ad::rss::world::LateralRssAccelerationValues valueAlphaLat; 47 : 12 : ::ad::physics::Acceleration valueAlphaLatAccelMax(-1e2); 48 : 12 : valueAlphaLatAccelMax = ::ad::physics::Acceleration(0.); // set to valid value within struct 49 : 12 : valueAlphaLat.accelMax = valueAlphaLatAccelMax; 50 : 12 : ::ad::physics::Acceleration valueAlphaLatBrakeMin(-1e2); 51 : 12 : valueAlphaLat.brakeMin = valueAlphaLatBrakeMin; 52 : 12 : value.alphaLat = valueAlphaLat; 53 : 12 : ::ad::physics::Distance valueLateralFluctuationMargin(-1e9); 54 : 12 : valueLateralFluctuationMargin = ::ad::physics::Distance(0.); // set to valid value within struct 55 : 12 : value.lateralFluctuationMargin = valueLateralFluctuationMargin; 56 : 12 : ::ad::physics::Duration valueResponseTime(0.); 57 : : valueResponseTime 58 : 12 : = ::ad::physics::Duration(0. + ::ad::physics::Duration::cPrecisionValue); // set to valid value within struct 59 : 12 : value.responseTime = valueResponseTime; 60 : 12 : ::ad::physics::Speed valueMaxSpeedOnAcceleration(-100.); 61 : 12 : value.maxSpeedOnAcceleration = valueMaxSpeedOnAcceleration; 62 : 12 : ::ad::rss::world::UnstructuredSettings valueUnstructuredSettings; 63 : 12 : ::ad::physics::Distance valueUnstructuredSettingsPedestrianTurningRadius(-1e9); 64 : 12 : valueUnstructuredSettings.pedestrianTurningRadius = valueUnstructuredSettingsPedestrianTurningRadius; 65 : 12 : ::ad::physics::Angle valueUnstructuredSettingsDriveAwayMaxAngle(-6.283185308); 66 : 12 : valueUnstructuredSettings.driveAwayMaxAngle = valueUnstructuredSettingsDriveAwayMaxAngle; 67 : 12 : ::ad::physics::AngularAcceleration valueUnstructuredSettingsVehicleYawRateChange(-1e2); 68 : 12 : valueUnstructuredSettings.vehicleYawRateChange = valueUnstructuredSettingsVehicleYawRateChange; 69 : 12 : ::ad::physics::Distance valueUnstructuredSettingsVehicleMinRadius(-1e9); 70 : 12 : valueUnstructuredSettings.vehicleMinRadius = valueUnstructuredSettingsVehicleMinRadius; 71 : 12 : ::ad::physics::Duration valueUnstructuredSettingsVehicleTrajectoryCalculationStep(0.); 72 : : valueUnstructuredSettings.vehicleTrajectoryCalculationStep 73 : 12 : = valueUnstructuredSettingsVehicleTrajectoryCalculationStep; 74 : 12 : uint32_t valueUnstructuredSettingsVehicleFrontIntermediateYawRateChangeRatioSteps{ 75 : : std::numeric_limits<uint32_t>::min()}; 76 : : valueUnstructuredSettings.vehicleFrontIntermediateYawRateChangeRatioSteps 77 : 12 : = valueUnstructuredSettingsVehicleFrontIntermediateYawRateChangeRatioSteps; 78 : 12 : uint32_t valueUnstructuredSettingsVehicleBackIntermediateYawRateChangeRatioSteps{ 79 : : std::numeric_limits<uint32_t>::min()}; 80 : : valueUnstructuredSettings.vehicleBackIntermediateYawRateChangeRatioSteps 81 : 12 : = valueUnstructuredSettingsVehicleBackIntermediateYawRateChangeRatioSteps; 82 : 12 : uint32_t valueUnstructuredSettingsVehicleBrakeIntermediateAccelerationSteps{std::numeric_limits<uint32_t>::min()}; 83 : : valueUnstructuredSettings.vehicleBrakeIntermediateAccelerationSteps 84 : 12 : = valueUnstructuredSettingsVehicleBrakeIntermediateAccelerationSteps; 85 : 12 : uint32_t valueUnstructuredSettingsVehicleContinueForwardIntermediateAccelerationSteps{ 86 : : std::numeric_limits<uint32_t>::min()}; 87 : : valueUnstructuredSettings.vehicleContinueForwardIntermediateAccelerationSteps 88 : 12 : = valueUnstructuredSettingsVehicleContinueForwardIntermediateAccelerationSteps; 89 : 12 : uint32_t valueUnstructuredSettingsVehicleContinueForwardIntermediateYawRateChangeRatioSteps{ 90 : : std::numeric_limits<uint32_t>::min()}; 91 : : valueUnstructuredSettings.vehicleContinueForwardIntermediateYawRateChangeRatioSteps 92 : 12 : = valueUnstructuredSettingsVehicleContinueForwardIntermediateYawRateChangeRatioSteps; 93 : 12 : uint32_t valueUnstructuredSettingsPedestrianContinueForwardIntermediateHeadingChangeRatioSteps{ 94 : : std::numeric_limits<uint32_t>::min()}; 95 : : valueUnstructuredSettings.pedestrianContinueForwardIntermediateHeadingChangeRatioSteps 96 : 12 : = valueUnstructuredSettingsPedestrianContinueForwardIntermediateHeadingChangeRatioSteps; 97 : 12 : uint32_t valueUnstructuredSettingsPedestrianContinueForwardIntermediateAccelerationSteps{ 98 : : std::numeric_limits<uint32_t>::min()}; 99 : : valueUnstructuredSettings.pedestrianContinueForwardIntermediateAccelerationSteps 100 : 12 : = valueUnstructuredSettingsPedestrianContinueForwardIntermediateAccelerationSteps; 101 : 12 : uint32_t valueUnstructuredSettingsPedestrianBrakeIntermediateAccelerationSteps{ 102 : : std::numeric_limits<uint32_t>::min()}; 103 : : valueUnstructuredSettings.pedestrianBrakeIntermediateAccelerationSteps 104 : 12 : = valueUnstructuredSettingsPedestrianBrakeIntermediateAccelerationSteps; 105 : 12 : uint32_t valueUnstructuredSettingsPedestrianFrontIntermediateHeadingChangeRatioSteps{ 106 : : std::numeric_limits<uint32_t>::min()}; 107 : : valueUnstructuredSettings.pedestrianFrontIntermediateHeadingChangeRatioSteps 108 : 12 : = valueUnstructuredSettingsPedestrianFrontIntermediateHeadingChangeRatioSteps; 109 : 12 : uint32_t valueUnstructuredSettingsPedestrianBackIntermediateHeadingChangeRatioSteps{ 110 : : std::numeric_limits<uint32_t>::min()}; 111 : : valueUnstructuredSettings.pedestrianBackIntermediateHeadingChangeRatioSteps 112 : 12 : = valueUnstructuredSettingsPedestrianBackIntermediateHeadingChangeRatioSteps; 113 : 12 : value.unstructuredSettings = valueUnstructuredSettings; 114 : 12 : mValue = value; 115 : 12 : } 116 : : 117 : : ::ad::rss::world::RssDynamics mValue; 118 : : }; 119 : : 120 : 2 : TEST_F(RssDynamicsTests, copyConstruction) 121 : : { 122 : 1 : ::ad::rss::world::RssDynamics value(mValue); 123 [ + - - + : 1 : EXPECT_EQ(mValue, value); - - - - - - ] 124 : 1 : } 125 : : 126 : 2 : TEST_F(RssDynamicsTests, moveConstruction) 127 : : { 128 : 1 : ::ad::rss::world::RssDynamics tmpValue(mValue); 129 : 1 : ::ad::rss::world::RssDynamics value(std::move(tmpValue)); 130 [ + - - + : 1 : EXPECT_EQ(mValue, value); - - - - - - ] 131 : 1 : } 132 : : 133 : 2 : TEST_F(RssDynamicsTests, copyAssignment) 134 : : { 135 : 1 : ::ad::rss::world::RssDynamics value; 136 : 1 : value = mValue; 137 [ + - - + : 1 : EXPECT_EQ(mValue, value); - - - - - - ] 138 : 1 : } 139 : : 140 : 2 : TEST_F(RssDynamicsTests, moveAssignment) 141 : : { 142 : 1 : ::ad::rss::world::RssDynamics tmpValue(mValue); 143 : 1 : ::ad::rss::world::RssDynamics value; 144 : 1 : value = std::move(tmpValue); 145 [ + - - + : 1 : EXPECT_EQ(mValue, value); - - - - - - ] 146 : 1 : } 147 : : 148 : 2 : TEST_F(RssDynamicsTests, comparisonOperatorEqual) 149 : : { 150 : 1 : ::ad::rss::world::RssDynamics valueA = mValue; 151 : 1 : ::ad::rss::world::RssDynamics valueB = mValue; 152 : : 153 [ + - - + : 1 : EXPECT_TRUE(valueA == valueB); - - - - - - - - ] 154 [ + - - + : 1 : EXPECT_FALSE(valueA != valueB); - - - - - - - - ] 155 : 1 : } 156 : : 157 : 2 : TEST_F(RssDynamicsTests, stringConversionTest) 158 : : { 159 [ + - ]: 1 : std::stringstream stream; 160 [ + - ]: 1 : stream << mValue; 161 [ + - ]: 1 : std::string ostreamStr = stream.str(); 162 [ + - ]: 1 : std::string toStr = std::to_string(mValue); 163 [ + - - + : 1 : ASSERT_EQ(ostreamStr, toStr); - - - - - - ] 164 : : } 165 : : 166 : 2 : TEST_F(RssDynamicsTests, comparisonOperatorAlphaLonDiffers) 167 : : { 168 : 1 : ::ad::rss::world::RssDynamics valueA = mValue; 169 : 1 : ::ad::rss::world::LongitudinalRssAccelerationValues alphaLon; 170 : 1 : ::ad::physics::Acceleration alphaLonAccelMax(1e2); 171 : 1 : alphaLon.accelMax = alphaLonAccelMax; 172 : 1 : ::ad::physics::Acceleration alphaLonBrakeMax(1e2); 173 : 1 : alphaLon.brakeMax = alphaLonBrakeMax; 174 : 1 : ::ad::physics::Acceleration alphaLonBrakeMin(1e2); 175 : 1 : alphaLon.brakeMin = alphaLonBrakeMin; 176 : 1 : ::ad::physics::Acceleration alphaLonBrakeMinCorrect(1e2); 177 : 1 : alphaLonBrakeMinCorrect = ::ad::physics::Acceleration(0. * 0.9); // set to valid value within struct 178 : 1 : alphaLon.brakeMinCorrect = alphaLonBrakeMinCorrect; 179 : 1 : alphaLon.brakeMinCorrect = alphaLon.brakeMin; 180 : 1 : alphaLon.brakeMin = alphaLon.brakeMax; 181 : 1 : alphaLon.brakeMax = alphaLon.brakeMin; 182 : 1 : alphaLon.brakeMin = alphaLon.brakeMinCorrect; 183 : 1 : valueA.alphaLon = alphaLon; 184 : 1 : ::ad::rss::world::RssDynamics valueB = mValue; 185 : : 186 [ + - - + : 1 : EXPECT_FALSE(valueA == valueB); - - - - - - - - ] 187 [ + - - + : 1 : EXPECT_TRUE(valueA != valueB); - - - - - - - - ] 188 : 1 : } 189 : : 190 : 2 : TEST_F(RssDynamicsTests, comparisonOperatorAlphaLatDiffers) 191 : : { 192 : 1 : ::ad::rss::world::RssDynamics valueA = mValue; 193 : 1 : ::ad::rss::world::LateralRssAccelerationValues alphaLat; 194 : 1 : ::ad::physics::Acceleration alphaLatAccelMax(1e2); 195 : 1 : alphaLat.accelMax = alphaLatAccelMax; 196 : 1 : ::ad::physics::Acceleration alphaLatBrakeMin(1e2); 197 : 1 : alphaLatBrakeMin = ::ad::physics::Acceleration(0. * 0.9); // set to valid value within struct 198 : 1 : alphaLat.brakeMin = alphaLatBrakeMin; 199 : 1 : valueA.alphaLat = alphaLat; 200 : 1 : ::ad::rss::world::RssDynamics valueB = mValue; 201 : : 202 [ + - - + : 1 : EXPECT_FALSE(valueA == valueB); - - - - - - - - ] 203 [ + - - + : 1 : EXPECT_TRUE(valueA != valueB); - - - - - - - - ] 204 : 1 : } 205 : : 206 : 2 : TEST_F(RssDynamicsTests, comparisonOperatorLateralFluctuationMarginDiffers) 207 : : { 208 : 1 : ::ad::rss::world::RssDynamics valueA = mValue; 209 : 1 : ::ad::physics::Distance lateralFluctuationMargin(1e9); 210 : 1 : valueA.lateralFluctuationMargin = lateralFluctuationMargin; 211 : 1 : ::ad::rss::world::RssDynamics valueB = mValue; 212 : : 213 [ + - - + : 1 : EXPECT_FALSE(valueA == valueB); - - - - - - - - ] 214 [ + - - + : 1 : EXPECT_TRUE(valueA != valueB); - - - - - - - - ] 215 : 1 : } 216 : : 217 : 2 : TEST_F(RssDynamicsTests, comparisonOperatorResponseTimeDiffers) 218 : : { 219 : 1 : ::ad::rss::world::RssDynamics valueA = mValue; 220 : 1 : ::ad::physics::Duration responseTime(1e6); 221 : 1 : valueA.responseTime = responseTime; 222 : 1 : ::ad::rss::world::RssDynamics valueB = mValue; 223 : : 224 [ + - - + : 1 : EXPECT_FALSE(valueA == valueB); - - - - - - - - ] 225 [ + - - + : 1 : EXPECT_TRUE(valueA != valueB); - - - - - - - - ] 226 : 1 : } 227 : : 228 : 2 : TEST_F(RssDynamicsTests, comparisonOperatorMaxSpeedOnAccelerationDiffers) 229 : : { 230 : 1 : ::ad::rss::world::RssDynamics valueA = mValue; 231 : 1 : ::ad::physics::Speed maxSpeedOnAcceleration(100.); 232 : 1 : valueA.maxSpeedOnAcceleration = maxSpeedOnAcceleration; 233 : 1 : ::ad::rss::world::RssDynamics valueB = mValue; 234 : : 235 [ + - - + : 1 : EXPECT_FALSE(valueA == valueB); - - - - - - - - ] 236 [ + - - + : 1 : EXPECT_TRUE(valueA != valueB); - - - - - - - - ] 237 : 1 : } 238 : : 239 : 2 : TEST_F(RssDynamicsTests, comparisonOperatorUnstructuredSettingsDiffers) 240 : : { 241 : 1 : ::ad::rss::world::RssDynamics valueA = mValue; 242 : 1 : ::ad::rss::world::UnstructuredSettings unstructuredSettings; 243 : 1 : ::ad::physics::Distance unstructuredSettingsPedestrianTurningRadius(1e9); 244 : 1 : unstructuredSettings.pedestrianTurningRadius = unstructuredSettingsPedestrianTurningRadius; 245 : 1 : ::ad::physics::Angle unstructuredSettingsDriveAwayMaxAngle(6.283185308); 246 : 1 : unstructuredSettings.driveAwayMaxAngle = unstructuredSettingsDriveAwayMaxAngle; 247 : 1 : ::ad::physics::AngularAcceleration unstructuredSettingsVehicleYawRateChange(1e2); 248 : 1 : unstructuredSettings.vehicleYawRateChange = unstructuredSettingsVehicleYawRateChange; 249 : 1 : ::ad::physics::Distance unstructuredSettingsVehicleMinRadius(1e9); 250 : 1 : unstructuredSettings.vehicleMinRadius = unstructuredSettingsVehicleMinRadius; 251 : 1 : ::ad::physics::Duration unstructuredSettingsVehicleTrajectoryCalculationStep(1e6); 252 : 1 : unstructuredSettings.vehicleTrajectoryCalculationStep = unstructuredSettingsVehicleTrajectoryCalculationStep; 253 : 1 : uint32_t unstructuredSettingsVehicleFrontIntermediateYawRateChangeRatioSteps{std::numeric_limits<uint32_t>::max()}; 254 : : unstructuredSettings.vehicleFrontIntermediateYawRateChangeRatioSteps 255 : 1 : = unstructuredSettingsVehicleFrontIntermediateYawRateChangeRatioSteps; 256 : 1 : uint32_t unstructuredSettingsVehicleBackIntermediateYawRateChangeRatioSteps{std::numeric_limits<uint32_t>::max()}; 257 : : unstructuredSettings.vehicleBackIntermediateYawRateChangeRatioSteps 258 : 1 : = unstructuredSettingsVehicleBackIntermediateYawRateChangeRatioSteps; 259 : 1 : uint32_t unstructuredSettingsVehicleBrakeIntermediateAccelerationSteps{std::numeric_limits<uint32_t>::max()}; 260 : : unstructuredSettings.vehicleBrakeIntermediateAccelerationSteps 261 : 1 : = unstructuredSettingsVehicleBrakeIntermediateAccelerationSteps; 262 : 1 : uint32_t unstructuredSettingsVehicleContinueForwardIntermediateAccelerationSteps{ 263 : : std::numeric_limits<uint32_t>::max()}; 264 : : unstructuredSettings.vehicleContinueForwardIntermediateAccelerationSteps 265 : 1 : = unstructuredSettingsVehicleContinueForwardIntermediateAccelerationSteps; 266 : 1 : uint32_t unstructuredSettingsVehicleContinueForwardIntermediateYawRateChangeRatioSteps{ 267 : : std::numeric_limits<uint32_t>::max()}; 268 : : unstructuredSettings.vehicleContinueForwardIntermediateYawRateChangeRatioSteps 269 : 1 : = unstructuredSettingsVehicleContinueForwardIntermediateYawRateChangeRatioSteps; 270 : 1 : uint32_t unstructuredSettingsPedestrianContinueForwardIntermediateHeadingChangeRatioSteps{ 271 : : std::numeric_limits<uint32_t>::max()}; 272 : : unstructuredSettings.pedestrianContinueForwardIntermediateHeadingChangeRatioSteps 273 : 1 : = unstructuredSettingsPedestrianContinueForwardIntermediateHeadingChangeRatioSteps; 274 : 1 : uint32_t unstructuredSettingsPedestrianContinueForwardIntermediateAccelerationSteps{ 275 : : std::numeric_limits<uint32_t>::max()}; 276 : : unstructuredSettings.pedestrianContinueForwardIntermediateAccelerationSteps 277 : 1 : = unstructuredSettingsPedestrianContinueForwardIntermediateAccelerationSteps; 278 : 1 : uint32_t unstructuredSettingsPedestrianBrakeIntermediateAccelerationSteps{std::numeric_limits<uint32_t>::max()}; 279 : : unstructuredSettings.pedestrianBrakeIntermediateAccelerationSteps 280 : 1 : = unstructuredSettingsPedestrianBrakeIntermediateAccelerationSteps; 281 : 1 : uint32_t unstructuredSettingsPedestrianFrontIntermediateHeadingChangeRatioSteps{std::numeric_limits<uint32_t>::max()}; 282 : : unstructuredSettings.pedestrianFrontIntermediateHeadingChangeRatioSteps 283 : 1 : = unstructuredSettingsPedestrianFrontIntermediateHeadingChangeRatioSteps; 284 : 1 : uint32_t unstructuredSettingsPedestrianBackIntermediateHeadingChangeRatioSteps{std::numeric_limits<uint32_t>::max()}; 285 : : unstructuredSettings.pedestrianBackIntermediateHeadingChangeRatioSteps 286 : 1 : = unstructuredSettingsPedestrianBackIntermediateHeadingChangeRatioSteps; 287 : 1 : valueA.unstructuredSettings = unstructuredSettings; 288 : 1 : ::ad::rss::world::RssDynamics valueB = mValue; 289 : : 290 [ + - - + : 1 : EXPECT_FALSE(valueA == valueB); - - - - - - - - ] 291 [ + - - + : 1 : EXPECT_TRUE(valueA != valueB); - - - - - - - - ] 292 : 1 : } 293 : : 294 : : #if defined(__clang__) && (__clang_major__ >= 7) 295 : : #pragma GCC diagnostic pop 296 : : #endif