scenario_simulator_v2 C++ API
common
math
geometry
test
src
expect_eq_macros.hpp
Go to the documentation of this file.
1
// Copyright 2015 TIER IV, Inc. All rights reserved.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#ifndef TRAFFIC_SIMULATOR__TEST__EXPECT_EQ_MACROS_HPP_
16
#define TRAFFIC_SIMULATOR__TEST__EXPECT_EQ_MACROS_HPP_
17
18
#include <gtest/gtest.h>
19
20
#include <geometry_msgs/msg/point.hpp>
21
#include <geometry_msgs/msg/vector3.hpp>
22
23
#define EXPECT_DECIMAL_EQ(DATA0, DATA1, TOLERANCE) \
24
EXPECT_TRUE(std::fabs(DATA0 - DATA1) <= std::fabs(TOLERANCE));
25
26
#define EXPECT_POINT_EQ(DATA0, DATA1) \
27
EXPECT_DOUBLE_EQ(DATA0.x, DATA1.x); \
28
EXPECT_DOUBLE_EQ(DATA0.y, DATA1.y); \
29
EXPECT_DOUBLE_EQ(DATA0.z, DATA1.z);
30
31
#define EXPECT_BOOST_POINT_2D_AND_POINT_EQ(DATA0, DATA1) \
32
EXPECT_DOUBLE_EQ(DATA0.x(), DATA1.x); \
33
EXPECT_DOUBLE_EQ(DATA0.y(), DATA1.y);
34
35
#define EXPECT_POINT_NEAR(DATA0, DATA1, TOLERANCE) \
36
EXPECT_NEAR(DATA0.x, DATA1.x, TOLERANCE); \
37
EXPECT_NEAR(DATA0.y, DATA1.y, TOLERANCE); \
38
EXPECT_NEAR(DATA0.z, DATA1.z, TOLERANCE);
39
40
#define EXPECT_POINT_NAN(DATA) \
41
EXPECT_TRUE(std::isnan(DATA.x)); \
42
EXPECT_TRUE(std::isnan(DATA.y)); \
43
EXPECT_TRUE(std::isnan(DATA.z));
44
45
#define EXPECT_VECTOR3_EQ(DATA0, DATA1) \
46
EXPECT_DOUBLE_EQ(DATA0.x, DATA1.x); \
47
EXPECT_DOUBLE_EQ(DATA0.y, DATA1.y); \
48
EXPECT_DOUBLE_EQ(DATA0.z, DATA1.z);
49
50
#define EXPECT_VECTOR3_NEAR(DATA0, DATA1, TOLERANCE) \
51
EXPECT_NEAR(DATA0.x, DATA1.x, TOLERANCE); \
52
EXPECT_NEAR(DATA0.y, DATA1.y, TOLERANCE); \
53
EXPECT_NEAR(DATA0.z, DATA1.z, TOLERANCE);
54
55
#define EXPECT_QUATERNION_EQ(DATA0, DATA1) \
56
EXPECT_DOUBLE_EQ(DATA0.x, DATA1.x); \
57
EXPECT_DOUBLE_EQ(DATA0.y, DATA1.y); \
58
EXPECT_DOUBLE_EQ(DATA0.z, DATA1.z); \
59
EXPECT_DOUBLE_EQ(DATA0.w, DATA1.w);
60
61
#define EXPECT_QUATERNION_NEAR(DATA0, DATA1, TOLERANCE) \
62
EXPECT_NEAR(DATA0.x, DATA1.x, TOLERANCE); \
63
EXPECT_NEAR(DATA0.y, DATA1.y, TOLERANCE); \
64
EXPECT_NEAR(DATA0.z, DATA1.z, TOLERANCE); \
65
EXPECT_NEAR(DATA0.w, DATA1.w, TOLERANCE);
66
67
#define EXPECT_POSE_EQ(DATA0, DATA1) \
68
EXPECT_POINT_EQ(DATA0.position, DATA1.position); \
69
EXPECT_QUATERNION_EQ(DATA0.orientation, DATA1.orientation);
70
71
#define EXPECT_POSE_NEAR(DATA0, DATA1, TOLERANCE) \
72
EXPECT_POINT_NEAR(DATA0.position, DATA1.position, TOLERANCE); \
73
EXPECT_QUATERNION_NEAR(DATA0.orientation, DATA1.orientation, TOLERANCE);
74
75
#define EXPECT_LANELET_POSE_EQ(DATA0, DATA1) \
76
EXPECT_EQ(DATA0.lanelet_id, DATA1.lanelet_id); \
77
EXPECT_DOUBLE_EQ(DATA0.s, DATA1.s); \
78
EXPECT_DOUBLE_EQ(DATA0.offset, DATA1.offset); \
79
EXPECT_VECTOR3_EQ(DATA0.rpy, DATA1.rpy);
80
81
#define EXPECT_TWIST_EQ(DATA0, DATA1) \
82
EXPECT_VECTOR3_EQ(DATA0.linear, DATA1.linear); \
83
EXPECT_VECTOR3_EQ(DATA0.angular, DATA1.angular);
84
85
#define EXPECT_ACCEL_EQ(DATA0, DATA1) \
86
EXPECT_VECTOR3_EQ(DATA0.linear, DATA1.linear); \
87
EXPECT_VECTOR3_EQ(DATA0.angular, DATA1.angular);
88
89
#define EXPECT_ACTION_STATUS_EQ(DATA0, DATA1) \
90
EXPECT_ACCEL_EQ(DATA0.accel, DATA1.accel); \
91
EXPECT_TWIST_EQ(DATA0.twist, DATA1.twist); \
92
EXPECT_STREQ(DATA0.current_action.c_str(), DATA1.current_action.c_str());
93
94
#define EXPECT_DETECTION_SENSOR_CONFIGURATION_EQ(DATA0, DATA1) \
95
EXPECT_STREQ(DATA0.entity().c_str(), DATA1.entity().c_str()); \
96
EXPECT_STREQ(DATA0.architecture_type().c_str(), DATA1.architecture_type().c_str()); \
97
EXPECT_DOUBLE_EQ(DATA0.update_duration(), DATA1.update_duration());
98
99
#endif
// TRAFFIC_SIMULATOR__TEST__EXPECT_EQ_MACROS_HPP_
Generated by
1.9.1