Branch data Line data Source code
1 : : /* 2 : : * ----------------- BEGIN LICENSE BLOCK --------------------------------- 3 : : * 4 : : * Copyright (C) 2018-2022 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/core/StructuredObjectState.hpp" 23 : : 24 : : class StructuredObjectStateTests : public testing::Test 25 : : { 26 : : protected: 27 : 11 : virtual void SetUp() override 28 : : { 29 : : // valid initialization 30 : 11 : ::ad::rss::core::StructuredObjectState value; 31 : 11 : ::ad::rss::world::Velocity valueVelocity; 32 : 11 : ::ad::physics::Speed valueVelocitySpeed_lon_min(-100.); 33 : 11 : valueVelocitySpeed_lon_min = ::ad::physics::Speed(0.); // set to valid value within struct 34 : 11 : valueVelocity.speed_lon_min = valueVelocitySpeed_lon_min; 35 : 11 : ::ad::physics::Speed valueVelocitySpeed_lon_max(-100.); 36 : 11 : valueVelocity.speed_lon_max = valueVelocitySpeed_lon_max; 37 : 11 : ::ad::physics::Speed valueVelocitySpeed_lat_min(-100.); 38 : 11 : valueVelocity.speed_lat_min = valueVelocitySpeed_lat_min; 39 : 11 : ::ad::physics::Speed valueVelocitySpeed_lat_max(-100.); 40 : 11 : valueVelocity.speed_lat_max = valueVelocitySpeed_lat_max; 41 : 11 : valueVelocity.speed_lon_max = valueVelocity.speed_lon_min; 42 : 11 : valueVelocity.speed_lat_max = valueVelocity.speed_lat_min; 43 : 11 : valueVelocity.speed_lon_min = valueVelocity.speed_lon_max; 44 : 11 : valueVelocity.speed_lat_min = valueVelocity.speed_lat_max; 45 : 11 : value.velocity = valueVelocity; 46 : 11 : bool valueHas_priority{true}; 47 : 11 : value.has_priority = valueHas_priority; 48 : 11 : bool valueIs_in_correct_lane{true}; 49 : 11 : value.is_in_correct_lane = valueIs_in_correct_lane; 50 : 11 : ::ad::physics::Distance valueDistance_to_enter_intersection(-1e9); 51 : 11 : valueDistance_to_enter_intersection = ::ad::physics::Distance(0.); // set to valid value within struct 52 : 11 : value.distance_to_enter_intersection = valueDistance_to_enter_intersection; 53 : 11 : ::ad::physics::Distance valueDistance_to_leave_intersection(-1e9); 54 : 11 : value.distance_to_leave_intersection = valueDistance_to_leave_intersection; 55 : 11 : value.distance_to_leave_intersection = value.distance_to_enter_intersection; 56 : 11 : value.distance_to_enter_intersection = value.distance_to_leave_intersection; 57 : 11 : mValue = value; 58 : 11 : } 59 : : 60 : : ::ad::rss::core::StructuredObjectState mValue; 61 : : }; 62 : : 63 : 4 : TEST_F(StructuredObjectStateTests, copyConstruction) 64 : : { 65 : 1 : ::ad::rss::core::StructuredObjectState value(mValue); 66 [ + - - + : 1 : EXPECT_EQ(mValue, value); - - - - - - ] 67 : 1 : } 68 : : 69 : 4 : TEST_F(StructuredObjectStateTests, moveConstruction) 70 : : { 71 : 1 : ::ad::rss::core::StructuredObjectState tmpValue(mValue); 72 : 1 : ::ad::rss::core::StructuredObjectState value(std::move(tmpValue)); 73 [ + - - + : 1 : EXPECT_EQ(mValue, value); - - - - - - ] 74 : 1 : } 75 : : 76 : 4 : TEST_F(StructuredObjectStateTests, copyAssignment) 77 : : { 78 : 1 : ::ad::rss::core::StructuredObjectState value; 79 : 1 : value = mValue; 80 [ + - - + : 1 : EXPECT_EQ(mValue, value); - - - - - - ] 81 : 1 : } 82 : : 83 : 4 : TEST_F(StructuredObjectStateTests, moveAssignment) 84 : : { 85 : 1 : ::ad::rss::core::StructuredObjectState tmpValue(mValue); 86 : 1 : ::ad::rss::core::StructuredObjectState value; 87 : 1 : value = std::move(tmpValue); 88 [ + - - + : 1 : EXPECT_EQ(mValue, value); - - - - - - ] 89 : 1 : } 90 : : 91 : 4 : TEST_F(StructuredObjectStateTests, comparisonOperatorEqual) 92 : : { 93 : 1 : ::ad::rss::core::StructuredObjectState valueA = mValue; 94 : 1 : ::ad::rss::core::StructuredObjectState valueB = mValue; 95 : : 96 [ + - - + : 1 : EXPECT_TRUE(valueA == valueB); - - - - - - - - ] 97 [ + - - + : 1 : EXPECT_FALSE(valueA != valueB); - - - - - - - - ] 98 : 1 : } 99 : : 100 : 4 : TEST_F(StructuredObjectStateTests, stringConversionTest) 101 : : { 102 [ + - ]: 1 : std::stringstream stream; 103 [ + - ]: 1 : stream << mValue; 104 [ + - ]: 1 : std::string ostreamStr = stream.str(); 105 [ + - ]: 1 : std::string toStr = std::to_string(mValue); 106 [ + - - + : 1 : ASSERT_EQ(ostreamStr, toStr); - - - - - - + - ] 107 [ + - + - : 1 : } + - ] 108 : : 109 : 4 : TEST_F(StructuredObjectStateTests, comparisonOperatorVelocityDiffers) 110 : : { 111 : 1 : ::ad::rss::core::StructuredObjectState valueA = mValue; 112 : 1 : ::ad::rss::world::Velocity velocity; 113 : 1 : ::ad::physics::Speed velocitySpeed_lon_min(100.); 114 : 1 : velocity.speed_lon_min = velocitySpeed_lon_min; 115 : 1 : ::ad::physics::Speed velocitySpeed_lon_max(100.); 116 : 1 : velocity.speed_lon_max = velocitySpeed_lon_max; 117 : 1 : ::ad::physics::Speed velocitySpeed_lat_min(100.); 118 : 1 : velocity.speed_lat_min = velocitySpeed_lat_min; 119 : 1 : ::ad::physics::Speed velocitySpeed_lat_max(100.); 120 : 1 : velocity.speed_lat_max = velocitySpeed_lat_max; 121 : 1 : velocity.speed_lat_max = velocity.speed_lat_min; 122 : 1 : velocity.speed_lon_max = velocity.speed_lon_min; 123 : 1 : velocity.speed_lat_min = velocity.speed_lat_max; 124 : 1 : velocity.speed_lon_min = velocity.speed_lon_max; 125 : 1 : valueA.velocity = velocity; 126 : 1 : ::ad::rss::core::StructuredObjectState valueB = mValue; 127 : : 128 [ + - - + : 1 : EXPECT_FALSE(valueA == valueB); - - - - - - - - ] 129 [ + - - + : 1 : EXPECT_TRUE(valueA != valueB); - - - - - - - - ] 130 : 1 : } 131 : : 132 : 4 : TEST_F(StructuredObjectStateTests, comparisonOperatorHas_priorityDiffers) 133 : : { 134 : 1 : ::ad::rss::core::StructuredObjectState valueA = mValue; 135 : 1 : bool has_priority{false}; 136 : 1 : valueA.has_priority = has_priority; 137 : 1 : ::ad::rss::core::StructuredObjectState valueB = mValue; 138 : : 139 [ + - - + : 1 : EXPECT_FALSE(valueA == valueB); - - - - - - - - ] 140 [ + - - + : 1 : EXPECT_TRUE(valueA != valueB); - - - - - - - - ] 141 : 1 : } 142 : : 143 : 4 : TEST_F(StructuredObjectStateTests, comparisonOperatorIs_in_correct_laneDiffers) 144 : : { 145 : 1 : ::ad::rss::core::StructuredObjectState valueA = mValue; 146 : 1 : bool is_in_correct_lane{false}; 147 : 1 : valueA.is_in_correct_lane = is_in_correct_lane; 148 : 1 : ::ad::rss::core::StructuredObjectState valueB = mValue; 149 : : 150 [ + - - + : 1 : EXPECT_FALSE(valueA == valueB); - - - - - - - - ] 151 [ + - - + : 1 : EXPECT_TRUE(valueA != valueB); - - - - - - - - ] 152 : 1 : } 153 : : 154 : 4 : TEST_F(StructuredObjectStateTests, comparisonOperatorDistance_to_enter_intersectionDiffers) 155 : : { 156 : 1 : ::ad::rss::core::StructuredObjectState valueA = mValue; 157 : 1 : ::ad::physics::Distance distance_to_enter_intersection(1e9); 158 : 1 : valueA.distance_to_enter_intersection = distance_to_enter_intersection; 159 : 1 : ::ad::rss::core::StructuredObjectState valueB = mValue; 160 : : 161 [ + - - + : 1 : EXPECT_FALSE(valueA == valueB); - - - - - - - - ] 162 [ + - - + : 1 : EXPECT_TRUE(valueA != valueB); - - - - - - - - ] 163 : 1 : } 164 : : 165 : 4 : TEST_F(StructuredObjectStateTests, comparisonOperatorDistance_to_leave_intersectionDiffers) 166 : : { 167 : 1 : ::ad::rss::core::StructuredObjectState valueA = mValue; 168 : 1 : ::ad::physics::Distance distance_to_leave_intersection(1e9); 169 : 1 : valueA.distance_to_leave_intersection = distance_to_leave_intersection; 170 : 1 : ::ad::rss::core::StructuredObjectState valueB = mValue; 171 : : 172 [ + - - + : 1 : EXPECT_FALSE(valueA == valueB); - - - - - - - - ] 173 [ + - - + : 1 : EXPECT_TRUE(valueA != valueB); - - - - - - - - ] 174 : 1 : } 175 : : 176 : : #if defined(__clang__) && (__clang_major__ >= 7) 177 : : #pragma GCC diagnostic pop 178 : : #endif