Deprecated is_initialized() (#967)
The function was previously documented as being deprecated, but this change adds compiler warnings if it is used. Ignore compiler warnings where the function is being tested and change to the preferred usage elsewhere. Signed-off-by: Jacob Perron <jacob@openrobotics.org>
This commit is contained in:
parent
54ad49703a
commit
7a8606fb39
3 changed files with 16 additions and 1 deletions
|
@ -154,6 +154,7 @@ ok(rclcpp::Context::SharedPtr context = nullptr);
|
||||||
* \return true if the context is initialized, and false otherwise
|
* \return true if the context is initialized, and false otherwise
|
||||||
*/
|
*/
|
||||||
RCLCPP_PUBLIC
|
RCLCPP_PUBLIC
|
||||||
|
[[deprecated("use the function ok() instead, which has the same usage.")]]
|
||||||
bool
|
bool
|
||||||
is_initialized(rclcpp::Context::SharedPtr context = nullptr);
|
is_initialized(rclcpp::Context::SharedPtr context = nullptr);
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,14 @@
|
||||||
#include "rclcpp/exceptions.hpp"
|
#include "rclcpp/exceptions.hpp"
|
||||||
#include "rclcpp/utilities.hpp"
|
#include "rclcpp/utilities.hpp"
|
||||||
|
|
||||||
|
#if !defined(_WIN32)
|
||||||
|
# pragma GCC diagnostic push
|
||||||
|
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
#else // !defined(_WIN32)
|
||||||
|
# pragma warning(push)
|
||||||
|
# pragma warning(disable: 4996)
|
||||||
|
#endif
|
||||||
|
|
||||||
TEST(TestInit, is_initialized) {
|
TEST(TestInit, is_initialized) {
|
||||||
EXPECT_FALSE(rclcpp::is_initialized());
|
EXPECT_FALSE(rclcpp::is_initialized());
|
||||||
|
|
||||||
|
@ -50,3 +58,9 @@ TEST(TestInit, initialize_with_unknown_ros_args) {
|
||||||
|
|
||||||
EXPECT_FALSE(rclcpp::is_initialized());
|
EXPECT_FALSE(rclcpp::is_initialized());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(_WIN32)
|
||||||
|
# pragma GCC diagnostic pop
|
||||||
|
#else // !defined(_WIN32)
|
||||||
|
# pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
|
@ -28,7 +28,7 @@ class TestPublisher : public ::testing::Test
|
||||||
public:
|
public:
|
||||||
static void SetUpTestCase()
|
static void SetUpTestCase()
|
||||||
{
|
{
|
||||||
if (!rclcpp::is_initialized()) {
|
if (!rclcpp::ok()) {
|
||||||
rclcpp::init(0, nullptr);
|
rclcpp::init(0, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue