11
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
- #include < gtest/gtest.h>
15
-
16
14
#include " service_log_checker.hpp"
17
- #include < rclcpp/node_options.hpp>
18
- #include < yaml-cpp/yaml.h>
15
+
19
16
#include < ament_index_cpp/get_package_share_directory.hpp>
17
+ #include < rclcpp/node_options.hpp>
20
18
#include < rclcpp_components/register_node_macro.hpp>
19
+
20
+ #include < gtest/gtest.h>
21
+ #include < yaml-cpp/yaml.h>
22
+
21
23
#include < memory>
22
24
#include < string>
23
25
@@ -27,38 +29,38 @@ using ServiceLogChecker = autoware::component_interface_tools::ServiceLogChecker
27
29
28
30
TEST (ServiceCheckerTest, ServiceChecker)
29
31
{
30
- class PubManager : public rclcpp ::Node
32
+ class PubManager : public rclcpp ::Node
33
+ {
34
+ public:
35
+ PubManager () : Node(" test_pub_node" )
31
36
{
32
- public:
33
- PubManager () : Node(" test_pub_node" )
34
- {
35
- pub_odom_ = create_publisher<ServiceLog>(" service_log" , 1 );
36
- sub_odom_ = create_subscription<DiagnosticArray>(
37
- " /diagnostics" , 1 , std::bind (&PubManager::on_service_log, this , std::placeholders::_1));
38
- }
39
- rclcpp::Publisher<ServiceLog>::SharedPtr pub_odom_;
40
- rclcpp::Subscription<DiagnosticArray>::SharedPtr sub_odom_;
41
- bool flag = false ;
42
- void on_service_log (const DiagnosticArray::ConstSharedPtr msg)
43
- {
44
- if (msg->status .size () > 0 ) {
45
- auto diag_array = msg->status [0 ].message .c_str ();
46
- EXPECT_EQ (diag_array, " ERROR" );
47
- flag = true ;
48
- }
37
+ pub_odom_ = create_publisher<ServiceLog>(" service_log" , 1 );
38
+ sub_odom_ = create_subscription<DiagnosticArray>(
39
+ " /diagnostics" , 1 , std::bind (&PubManager::on_service_log, this , std::placeholders::_1));
40
+ }
41
+ rclcpp::Publisher<ServiceLog>::SharedPtr pub_odom_;
42
+ rclcpp::Subscription<DiagnosticArray>::SharedPtr sub_odom_;
43
+ bool flag = false ;
44
+ void on_service_log (const DiagnosticArray::ConstSharedPtr msg)
45
+ {
46
+ if (msg->status .size () > 0 ) {
47
+ auto diag_array = msg->status [0 ].message .c_str ();
48
+ EXPECT_EQ (diag_array, " ERROR" );
49
+ flag = true ;
49
50
}
50
- };
51
-
52
- rclcpp::init (0 , nullptr );
53
- auto node_options = rclcpp::NodeOptions{};
54
- auto test_target_node = std::make_shared<ServiceLogChecker>(node_options);
55
- auto test_log = std::make_shared<PubManager>();
56
- ServiceLog log ;
57
- log .type = 6 ;
58
- log .name = " test" ;
59
- log .node = " test_node" ;
60
- test_log->pub_odom_ ->publish (log );
61
-
62
- while (!test_log->flag ) {
63
51
}
52
+ };
53
+
54
+ rclcpp::init (0 , nullptr );
55
+ auto node_options = rclcpp::NodeOptions{};
56
+ auto test_target_node = std::make_shared<ServiceLogChecker>(node_options);
57
+ auto test_log = std::make_shared<PubManager>();
58
+ ServiceLog log ;
59
+ log .type = 6 ;
60
+ log .name = " test" ;
61
+ log .node = " test_node" ;
62
+ test_log->pub_odom_ ->publish (log );
63
+
64
+ while (!test_log->flag ) {
65
+ }
64
66
}
0 commit comments