test
src
init_no_sim_time_test.cpp
Go to the documentation of this file.
1
/*
2
* Software License Agreement (BSD License)
3
*
4
* Copyright (c) 2023, Open Robotics
5
* All rights reserved.
6
*
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions
9
* are met:
10
*
11
* * Redistributions of source code must retain the above copyright
12
* notice, this list of conditions and the following disclaimer.
13
* * Redistributions in binary form must reproduce the above
14
* copyright notice, this list of conditions and the following
15
* disclaimer in the documentation and/or other materials provided
16
* with the distribution.
17
* * Neither the name of Willow Garage, Inc. nor the names of its
18
* contributors may be used to endorse or promote products derived
19
* from this software without specific prior written permission.
20
*
21
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
* POSSIBILITY OF SUCH DAMAGE.
33
*/
34
35
/* Author: Martin Pecka */
36
37
/*
38
* Test ros::init_options::NoSimTime.
39
*/
40
41
#include <gtest/gtest.h>
42
#include "
ros/ros.h
"
43
#include "
ros/topic_manager.h
"
44
45
TEST
(NoSimTime, isTimeValid)
46
{
47
// We should be using the system time, so time should be valid right away
48
ASSERT_TRUE(
ros::Time::isValid
());
49
50
// Check that the use_sim_time parameter is set to true
51
bool
use_sim_time =
false
;
52
ros::param::param
(
"/use_sim_time"
, use_sim_time, use_sim_time);
53
EXPECT_TRUE(use_sim_time);
54
EXPECT_TRUE(
ros::Time::isSystemTime
());
55
56
EXPECT_EQ(0u,
ros::TopicManager::instance
()->getNumSubscribers(
"/clock"
));
57
}
58
59
int
main
(
int
argc,
char
** argv)
60
{
61
testing::InitGoogleTest(&argc, argv);
62
ros::init
(argc, argv,
"sim_time_test"
,
ros::init_options::NoSimTime
);
63
ros::NodeHandle
nh;
64
return
RUN_ALL_TESTS();
65
}
66
topic_manager.h
ros::init
ROSCPP_DECL void init(const M_string &remappings, const std::string &name, uint32_t options=0)
ros.h
TEST
TEST(NoSimTime, isTimeValid)
Definition:
init_no_sim_time_test.cpp:45
ros::Time::isValid
static bool isValid()
ros::Time::isSystemTime
static bool isSystemTime()
ros::TopicManager::instance
static const TopicManagerPtr & instance()
main
int main(int argc, char **argv)
Definition:
init_no_sim_time_test.cpp:59
ros::init_options::NoSimTime
NoSimTime
ros::param::param
T param(const std::string ¶m_name, const T &default_val)
ros::NodeHandle
test_roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim, Dirk Thomas
, Jacob Perron
autogenerated on Sat Sep 14 2024 02:59:57