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 : : #include <gtest/gtest.h> 16 : : 17 : : #include <limits> 18 : : 19 : : #include "ad/rss/state/LongitudinalRssStateValidInputRange.hpp" 20 : : 21 : 2 : TEST(LongitudinalRssStateValidInputRangeTests, testValidInputRange) 22 : : { 23 : 1 : ::ad::rss::state::LongitudinalRssState value; 24 : 1 : bool valueIsSafe{true}; 25 : 1 : value.isSafe = valueIsSafe; 26 : 1 : ::ad::rss::state::LongitudinalResponse valueResponse(::ad::rss::state::LongitudinalResponse::None); 27 : 1 : value.response = valueResponse; 28 : 1 : ::ad::rss::world::LongitudinalRssAccelerationValues valueAlphaLon; 29 : 1 : ::ad::physics::Acceleration valueAlphaLonAccelMax(-1e2); 30 : 1 : valueAlphaLonAccelMax = ::ad::physics::Acceleration(0.); // set to valid value within struct 31 : 1 : valueAlphaLon.accelMax = valueAlphaLonAccelMax; 32 : 1 : ::ad::physics::Acceleration valueAlphaLonBrakeMax(-1e2); 33 : 1 : valueAlphaLon.brakeMax = valueAlphaLonBrakeMax; 34 : 1 : ::ad::physics::Acceleration valueAlphaLonBrakeMin(-1e2); 35 : 1 : valueAlphaLon.brakeMin = valueAlphaLonBrakeMin; 36 : 1 : ::ad::physics::Acceleration valueAlphaLonBrakeMinCorrect(-1e2); 37 : 1 : valueAlphaLon.brakeMinCorrect = valueAlphaLonBrakeMinCorrect; 38 : 1 : valueAlphaLon.brakeMin = valueAlphaLon.brakeMax; 39 : 1 : valueAlphaLon.brakeMinCorrect = valueAlphaLon.brakeMin; 40 : 1 : valueAlphaLon.brakeMin = valueAlphaLon.brakeMinCorrect; 41 : 1 : valueAlphaLon.brakeMax = valueAlphaLon.brakeMin; 42 : 1 : value.alphaLon = valueAlphaLon; 43 : 1 : ::ad::rss::state::RssStateInformation valueRssStateInformation; 44 : 1 : ::ad::physics::Distance valueRssStateInformationSafeDistance(-1e9); 45 : 1 : valueRssStateInformation.safeDistance = valueRssStateInformationSafeDistance; 46 : 1 : ::ad::physics::Distance valueRssStateInformationCurrentDistance(-1e9); 47 : 1 : valueRssStateInformation.currentDistance = valueRssStateInformationCurrentDistance; 48 : 1 : ::ad::rss::state::RssStateEvaluator valueRssStateInformationEvaluator(::ad::rss::state::RssStateEvaluator::None); 49 : 1 : valueRssStateInformation.evaluator = valueRssStateInformationEvaluator; 50 : 1 : value.rssStateInformation = valueRssStateInformation; 51 [ + - - + : 1 : ASSERT_TRUE(withinValidInputRange(value)); - - - - - - - - ] 52 : : } 53 : : 54 : 2 : TEST(LongitudinalRssStateValidInputRangeTests, testValidInputRangeResponseTooSmall) 55 : : { 56 : 1 : ::ad::rss::state::LongitudinalRssState value; 57 : 1 : bool valueIsSafe{true}; 58 : 1 : value.isSafe = valueIsSafe; 59 : 1 : ::ad::rss::state::LongitudinalResponse valueResponse(::ad::rss::state::LongitudinalResponse::None); 60 : 1 : value.response = valueResponse; 61 : 1 : ::ad::rss::world::LongitudinalRssAccelerationValues valueAlphaLon; 62 : 1 : ::ad::physics::Acceleration valueAlphaLonAccelMax(-1e2); 63 : 1 : valueAlphaLonAccelMax = ::ad::physics::Acceleration(0.); // set to valid value within struct 64 : 1 : valueAlphaLon.accelMax = valueAlphaLonAccelMax; 65 : 1 : ::ad::physics::Acceleration valueAlphaLonBrakeMax(-1e2); 66 : 1 : valueAlphaLon.brakeMax = valueAlphaLonBrakeMax; 67 : 1 : ::ad::physics::Acceleration valueAlphaLonBrakeMin(-1e2); 68 : 1 : valueAlphaLon.brakeMin = valueAlphaLonBrakeMin; 69 : 1 : ::ad::physics::Acceleration valueAlphaLonBrakeMinCorrect(-1e2); 70 : 1 : valueAlphaLon.brakeMinCorrect = valueAlphaLonBrakeMinCorrect; 71 : 1 : valueAlphaLon.brakeMin = valueAlphaLon.brakeMax; 72 : 1 : valueAlphaLon.brakeMinCorrect = valueAlphaLon.brakeMin; 73 : 1 : valueAlphaLon.brakeMin = valueAlphaLon.brakeMinCorrect; 74 : 1 : valueAlphaLon.brakeMax = valueAlphaLon.brakeMin; 75 : 1 : value.alphaLon = valueAlphaLon; 76 : 1 : ::ad::rss::state::RssStateInformation valueRssStateInformation; 77 : 1 : ::ad::physics::Distance valueRssStateInformationSafeDistance(-1e9); 78 : 1 : valueRssStateInformation.safeDistance = valueRssStateInformationSafeDistance; 79 : 1 : ::ad::physics::Distance valueRssStateInformationCurrentDistance(-1e9); 80 : 1 : valueRssStateInformation.currentDistance = valueRssStateInformationCurrentDistance; 81 : 1 : ::ad::rss::state::RssStateEvaluator valueRssStateInformationEvaluator(::ad::rss::state::RssStateEvaluator::None); 82 : 1 : valueRssStateInformation.evaluator = valueRssStateInformationEvaluator; 83 : 1 : value.rssStateInformation = valueRssStateInformation; 84 : : 85 : : // override member with data type value below input range minimum 86 : 1 : ::ad::rss::state::LongitudinalResponse invalidInitializedMember( 87 : : static_cast<::ad::rss::state::LongitudinalResponse>(-1)); 88 : 1 : value.response = invalidInitializedMember; 89 [ + - - + : 1 : ASSERT_FALSE(withinValidInputRange(value)); - - - - - - - - ] 90 : : } 91 : : 92 : 2 : TEST(LongitudinalRssStateValidInputRangeTests, testValidInputRangeResponseTooBig) 93 : : { 94 : 1 : ::ad::rss::state::LongitudinalRssState value; 95 : 1 : bool valueIsSafe{true}; 96 : 1 : value.isSafe = valueIsSafe; 97 : 1 : ::ad::rss::state::LongitudinalResponse valueResponse(::ad::rss::state::LongitudinalResponse::None); 98 : 1 : value.response = valueResponse; 99 : 1 : ::ad::rss::world::LongitudinalRssAccelerationValues valueAlphaLon; 100 : 1 : ::ad::physics::Acceleration valueAlphaLonAccelMax(-1e2); 101 : 1 : valueAlphaLonAccelMax = ::ad::physics::Acceleration(0.); // set to valid value within struct 102 : 1 : valueAlphaLon.accelMax = valueAlphaLonAccelMax; 103 : 1 : ::ad::physics::Acceleration valueAlphaLonBrakeMax(-1e2); 104 : 1 : valueAlphaLon.brakeMax = valueAlphaLonBrakeMax; 105 : 1 : ::ad::physics::Acceleration valueAlphaLonBrakeMin(-1e2); 106 : 1 : valueAlphaLon.brakeMin = valueAlphaLonBrakeMin; 107 : 1 : ::ad::physics::Acceleration valueAlphaLonBrakeMinCorrect(-1e2); 108 : 1 : valueAlphaLon.brakeMinCorrect = valueAlphaLonBrakeMinCorrect; 109 : 1 : valueAlphaLon.brakeMin = valueAlphaLon.brakeMax; 110 : 1 : valueAlphaLon.brakeMinCorrect = valueAlphaLon.brakeMin; 111 : 1 : valueAlphaLon.brakeMin = valueAlphaLon.brakeMinCorrect; 112 : 1 : valueAlphaLon.brakeMax = valueAlphaLon.brakeMin; 113 : 1 : value.alphaLon = valueAlphaLon; 114 : 1 : ::ad::rss::state::RssStateInformation valueRssStateInformation; 115 : 1 : ::ad::physics::Distance valueRssStateInformationSafeDistance(-1e9); 116 : 1 : valueRssStateInformation.safeDistance = valueRssStateInformationSafeDistance; 117 : 1 : ::ad::physics::Distance valueRssStateInformationCurrentDistance(-1e9); 118 : 1 : valueRssStateInformation.currentDistance = valueRssStateInformationCurrentDistance; 119 : 1 : ::ad::rss::state::RssStateEvaluator valueRssStateInformationEvaluator(::ad::rss::state::RssStateEvaluator::None); 120 : 1 : valueRssStateInformation.evaluator = valueRssStateInformationEvaluator; 121 : 1 : value.rssStateInformation = valueRssStateInformation; 122 : : 123 : : // override member with data type value above input range maximum 124 : 1 : ::ad::rss::state::LongitudinalResponse invalidInitializedMember( 125 : : static_cast<::ad::rss::state::LongitudinalResponse>(-1)); 126 : 1 : value.response = invalidInitializedMember; 127 [ + - - + : 1 : ASSERT_FALSE(withinValidInputRange(value)); - - - - - - - - ] 128 : : } 129 : : 130 : 2 : TEST(LongitudinalRssStateValidInputRangeTests, testValidInputRangeAlphaLonTooSmall) 131 : : { 132 : 1 : ::ad::rss::state::LongitudinalRssState value; 133 : 1 : bool valueIsSafe{true}; 134 : 1 : value.isSafe = valueIsSafe; 135 : 1 : ::ad::rss::state::LongitudinalResponse valueResponse(::ad::rss::state::LongitudinalResponse::None); 136 : 1 : value.response = valueResponse; 137 : 1 : ::ad::rss::world::LongitudinalRssAccelerationValues valueAlphaLon; 138 : 1 : ::ad::physics::Acceleration valueAlphaLonAccelMax(-1e2); 139 : 1 : valueAlphaLonAccelMax = ::ad::physics::Acceleration(0.); // set to valid value within struct 140 : 1 : valueAlphaLon.accelMax = valueAlphaLonAccelMax; 141 : 1 : ::ad::physics::Acceleration valueAlphaLonBrakeMax(-1e2); 142 : 1 : valueAlphaLon.brakeMax = valueAlphaLonBrakeMax; 143 : 1 : ::ad::physics::Acceleration valueAlphaLonBrakeMin(-1e2); 144 : 1 : valueAlphaLon.brakeMin = valueAlphaLonBrakeMin; 145 : 1 : ::ad::physics::Acceleration valueAlphaLonBrakeMinCorrect(-1e2); 146 : 1 : valueAlphaLon.brakeMinCorrect = valueAlphaLonBrakeMinCorrect; 147 : 1 : valueAlphaLon.brakeMin = valueAlphaLon.brakeMax; 148 : 1 : valueAlphaLon.brakeMinCorrect = valueAlphaLon.brakeMin; 149 : 1 : valueAlphaLon.brakeMin = valueAlphaLon.brakeMinCorrect; 150 : 1 : valueAlphaLon.brakeMax = valueAlphaLon.brakeMin; 151 : 1 : value.alphaLon = valueAlphaLon; 152 : 1 : ::ad::rss::state::RssStateInformation valueRssStateInformation; 153 : 1 : ::ad::physics::Distance valueRssStateInformationSafeDistance(-1e9); 154 : 1 : valueRssStateInformation.safeDistance = valueRssStateInformationSafeDistance; 155 : 1 : ::ad::physics::Distance valueRssStateInformationCurrentDistance(-1e9); 156 : 1 : valueRssStateInformation.currentDistance = valueRssStateInformationCurrentDistance; 157 : 1 : ::ad::rss::state::RssStateEvaluator valueRssStateInformationEvaluator(::ad::rss::state::RssStateEvaluator::None); 158 : 1 : valueRssStateInformation.evaluator = valueRssStateInformationEvaluator; 159 : 1 : value.rssStateInformation = valueRssStateInformation; 160 : : 161 : : // override member with data type value below input range minimum 162 : 1 : ::ad::rss::world::LongitudinalRssAccelerationValues invalidInitializedMember; 163 : 1 : ::ad::physics::Acceleration invalidInitializedMemberAccelMax(-1e2 * 1.1); 164 : 1 : invalidInitializedMember.accelMax = invalidInitializedMemberAccelMax; 165 : 1 : value.alphaLon = invalidInitializedMember; 166 [ + - - + : 1 : ASSERT_FALSE(withinValidInputRange(value)); - - - - - - - - ] 167 : : } 168 : : 169 : 2 : TEST(LongitudinalRssStateValidInputRangeTests, testValidInputRangeAlphaLonTooBig) 170 : : { 171 : 1 : ::ad::rss::state::LongitudinalRssState value; 172 : 1 : bool valueIsSafe{true}; 173 : 1 : value.isSafe = valueIsSafe; 174 : 1 : ::ad::rss::state::LongitudinalResponse valueResponse(::ad::rss::state::LongitudinalResponse::None); 175 : 1 : value.response = valueResponse; 176 : 1 : ::ad::rss::world::LongitudinalRssAccelerationValues valueAlphaLon; 177 : 1 : ::ad::physics::Acceleration valueAlphaLonAccelMax(-1e2); 178 : 1 : valueAlphaLonAccelMax = ::ad::physics::Acceleration(0.); // set to valid value within struct 179 : 1 : valueAlphaLon.accelMax = valueAlphaLonAccelMax; 180 : 1 : ::ad::physics::Acceleration valueAlphaLonBrakeMax(-1e2); 181 : 1 : valueAlphaLon.brakeMax = valueAlphaLonBrakeMax; 182 : 1 : ::ad::physics::Acceleration valueAlphaLonBrakeMin(-1e2); 183 : 1 : valueAlphaLon.brakeMin = valueAlphaLonBrakeMin; 184 : 1 : ::ad::physics::Acceleration valueAlphaLonBrakeMinCorrect(-1e2); 185 : 1 : valueAlphaLon.brakeMinCorrect = valueAlphaLonBrakeMinCorrect; 186 : 1 : valueAlphaLon.brakeMin = valueAlphaLon.brakeMax; 187 : 1 : valueAlphaLon.brakeMinCorrect = valueAlphaLon.brakeMin; 188 : 1 : valueAlphaLon.brakeMin = valueAlphaLon.brakeMinCorrect; 189 : 1 : valueAlphaLon.brakeMax = valueAlphaLon.brakeMin; 190 : 1 : value.alphaLon = valueAlphaLon; 191 : 1 : ::ad::rss::state::RssStateInformation valueRssStateInformation; 192 : 1 : ::ad::physics::Distance valueRssStateInformationSafeDistance(-1e9); 193 : 1 : valueRssStateInformation.safeDistance = valueRssStateInformationSafeDistance; 194 : 1 : ::ad::physics::Distance valueRssStateInformationCurrentDistance(-1e9); 195 : 1 : valueRssStateInformation.currentDistance = valueRssStateInformationCurrentDistance; 196 : 1 : ::ad::rss::state::RssStateEvaluator valueRssStateInformationEvaluator(::ad::rss::state::RssStateEvaluator::None); 197 : 1 : valueRssStateInformation.evaluator = valueRssStateInformationEvaluator; 198 : 1 : value.rssStateInformation = valueRssStateInformation; 199 : : 200 : : // override member with data type value above input range maximum 201 : 1 : ::ad::rss::world::LongitudinalRssAccelerationValues invalidInitializedMember; 202 : 1 : ::ad::physics::Acceleration invalidInitializedMemberAccelMax(1e2 * 1.1); 203 : 1 : invalidInitializedMember.accelMax = invalidInitializedMemberAccelMax; 204 : 1 : value.alphaLon = invalidInitializedMember; 205 [ + - - + : 1 : ASSERT_FALSE(withinValidInputRange(value)); - - - - - - - - ] 206 : : } 207 : : 208 : 2 : TEST(LongitudinalRssStateValidInputRangeTests, testValidInputRangeRssStateInformationTooSmall) 209 : : { 210 : 1 : ::ad::rss::state::LongitudinalRssState value; 211 : 1 : bool valueIsSafe{true}; 212 : 1 : value.isSafe = valueIsSafe; 213 : 1 : ::ad::rss::state::LongitudinalResponse valueResponse(::ad::rss::state::LongitudinalResponse::None); 214 : 1 : value.response = valueResponse; 215 : 1 : ::ad::rss::world::LongitudinalRssAccelerationValues valueAlphaLon; 216 : 1 : ::ad::physics::Acceleration valueAlphaLonAccelMax(-1e2); 217 : 1 : valueAlphaLonAccelMax = ::ad::physics::Acceleration(0.); // set to valid value within struct 218 : 1 : valueAlphaLon.accelMax = valueAlphaLonAccelMax; 219 : 1 : ::ad::physics::Acceleration valueAlphaLonBrakeMax(-1e2); 220 : 1 : valueAlphaLon.brakeMax = valueAlphaLonBrakeMax; 221 : 1 : ::ad::physics::Acceleration valueAlphaLonBrakeMin(-1e2); 222 : 1 : valueAlphaLon.brakeMin = valueAlphaLonBrakeMin; 223 : 1 : ::ad::physics::Acceleration valueAlphaLonBrakeMinCorrect(-1e2); 224 : 1 : valueAlphaLon.brakeMinCorrect = valueAlphaLonBrakeMinCorrect; 225 : 1 : valueAlphaLon.brakeMin = valueAlphaLon.brakeMax; 226 : 1 : valueAlphaLon.brakeMinCorrect = valueAlphaLon.brakeMin; 227 : 1 : valueAlphaLon.brakeMin = valueAlphaLon.brakeMinCorrect; 228 : 1 : valueAlphaLon.brakeMax = valueAlphaLon.brakeMin; 229 : 1 : value.alphaLon = valueAlphaLon; 230 : 1 : ::ad::rss::state::RssStateInformation valueRssStateInformation; 231 : 1 : ::ad::physics::Distance valueRssStateInformationSafeDistance(-1e9); 232 : 1 : valueRssStateInformation.safeDistance = valueRssStateInformationSafeDistance; 233 : 1 : ::ad::physics::Distance valueRssStateInformationCurrentDistance(-1e9); 234 : 1 : valueRssStateInformation.currentDistance = valueRssStateInformationCurrentDistance; 235 : 1 : ::ad::rss::state::RssStateEvaluator valueRssStateInformationEvaluator(::ad::rss::state::RssStateEvaluator::None); 236 : 1 : valueRssStateInformation.evaluator = valueRssStateInformationEvaluator; 237 : 1 : value.rssStateInformation = valueRssStateInformation; 238 : : 239 : : // override member with data type value below input range minimum 240 : 1 : ::ad::rss::state::RssStateInformation invalidInitializedMember; 241 : 1 : ::ad::physics::Distance invalidInitializedMemberSafeDistance(-1e9 * 1.1); 242 : 1 : invalidInitializedMember.safeDistance = invalidInitializedMemberSafeDistance; 243 : 1 : value.rssStateInformation = invalidInitializedMember; 244 [ + - - + : 1 : ASSERT_FALSE(withinValidInputRange(value)); - - - - - - - - ] 245 : : } 246 : : 247 : 2 : TEST(LongitudinalRssStateValidInputRangeTests, testValidInputRangeRssStateInformationTooBig) 248 : : { 249 : 1 : ::ad::rss::state::LongitudinalRssState value; 250 : 1 : bool valueIsSafe{true}; 251 : 1 : value.isSafe = valueIsSafe; 252 : 1 : ::ad::rss::state::LongitudinalResponse valueResponse(::ad::rss::state::LongitudinalResponse::None); 253 : 1 : value.response = valueResponse; 254 : 1 : ::ad::rss::world::LongitudinalRssAccelerationValues valueAlphaLon; 255 : 1 : ::ad::physics::Acceleration valueAlphaLonAccelMax(-1e2); 256 : 1 : valueAlphaLonAccelMax = ::ad::physics::Acceleration(0.); // set to valid value within struct 257 : 1 : valueAlphaLon.accelMax = valueAlphaLonAccelMax; 258 : 1 : ::ad::physics::Acceleration valueAlphaLonBrakeMax(-1e2); 259 : 1 : valueAlphaLon.brakeMax = valueAlphaLonBrakeMax; 260 : 1 : ::ad::physics::Acceleration valueAlphaLonBrakeMin(-1e2); 261 : 1 : valueAlphaLon.brakeMin = valueAlphaLonBrakeMin; 262 : 1 : ::ad::physics::Acceleration valueAlphaLonBrakeMinCorrect(-1e2); 263 : 1 : valueAlphaLon.brakeMinCorrect = valueAlphaLonBrakeMinCorrect; 264 : 1 : valueAlphaLon.brakeMin = valueAlphaLon.brakeMax; 265 : 1 : valueAlphaLon.brakeMinCorrect = valueAlphaLon.brakeMin; 266 : 1 : valueAlphaLon.brakeMin = valueAlphaLon.brakeMinCorrect; 267 : 1 : valueAlphaLon.brakeMax = valueAlphaLon.brakeMin; 268 : 1 : value.alphaLon = valueAlphaLon; 269 : 1 : ::ad::rss::state::RssStateInformation valueRssStateInformation; 270 : 1 : ::ad::physics::Distance valueRssStateInformationSafeDistance(-1e9); 271 : 1 : valueRssStateInformation.safeDistance = valueRssStateInformationSafeDistance; 272 : 1 : ::ad::physics::Distance valueRssStateInformationCurrentDistance(-1e9); 273 : 1 : valueRssStateInformation.currentDistance = valueRssStateInformationCurrentDistance; 274 : 1 : ::ad::rss::state::RssStateEvaluator valueRssStateInformationEvaluator(::ad::rss::state::RssStateEvaluator::None); 275 : 1 : valueRssStateInformation.evaluator = valueRssStateInformationEvaluator; 276 : 1 : value.rssStateInformation = valueRssStateInformation; 277 : : 278 : : // override member with data type value above input range maximum 279 : 1 : ::ad::rss::state::RssStateInformation invalidInitializedMember; 280 : 1 : ::ad::physics::Distance invalidInitializedMemberSafeDistance(1e9 * 1.1); 281 : 1 : invalidInitializedMember.safeDistance = invalidInitializedMemberSafeDistance; 282 : 1 : value.rssStateInformation = invalidInitializedMember; 283 [ + - - + : 1 : ASSERT_FALSE(withinValidInputRange(value)); - - - - - - - - ] 284 : : }