Skip to content

Commit

Permalink
Rename and uncrustify
Browse files Browse the repository at this point in the history
Signed-off-by: Ananya Muddukrishna <ananya.x.muddukrishna@ericsson.com>
  • Loading branch information
Ananya Muddukrishna committed Apr 1, 2021
1 parent 1851b6d commit e08a87b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 24 deletions.
20 changes: 12 additions & 8 deletions rcl/src/rcl/network_flow_endpoints.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ extern "C"
#endif

#include "rcl/error_handling.h"
#include "rcl/get_network_flow_endpoint.h"
#include "rcl/graph.h"
#include "rcl/network_flow_endpoints.h"
#include "rcl/publisher.h"
#include "rcl/subscription.h"

Expand All @@ -28,7 +28,7 @@ extern "C"
#include "rcutils/types.h"

#include "rmw/error_handling.h"
#include "rmw/network_flow_endpoints.h"
#include "rmw/get_network_flow_endpoints.h"
#include "rmw/network_flow_endpoint_array.h"
#include "rmw/types.h"

Expand Down Expand Up @@ -58,7 +58,7 @@ __validate_allocator_and_network_flow_endpoint_array(
}

rcl_ret_t
rcl_publisher_get_network_flow_endpoint(
rcl_publisher_get_network_flow_endpoints(
const rcl_publisher_t * publisher,
rcutils_allocator_t * allocator,
rcl_network_flow_endpoint_array_t * network_flow_endpoint_array)
Expand All @@ -67,13 +67,15 @@ rcl_publisher_get_network_flow_endpoint(
return RCL_RET_INVALID_ARGUMENT;
}

rcl_ret_t rcl_ret = __validate_allocator_and_network_flow_endpoint_array(allocator, network_flow_endpoint_array);
rcl_ret_t rcl_ret = __validate_allocator_and_network_flow_endpoint_array(
allocator,
network_flow_endpoint_array);
if (rcl_ret != RCL_RET_OK) {
return rcl_ret;
}

rmw_error_string_t error_string;
rmw_ret_t rmw_ret = rmw_publisher_get_network_flow_endpoint(
rmw_ret_t rmw_ret = rmw_publisher_get_network_flow_endpoints(
rcl_publisher_get_rmw_handle(publisher),
allocator,
network_flow_endpoint_array);
Expand All @@ -86,7 +88,7 @@ rcl_publisher_get_network_flow_endpoint(
}

rcl_ret_t
rcl_subscription_get_network_flow_endpoint(
rcl_subscription_get_network_flow_endpoints(
const rcl_subscription_t * subscription,
rcutils_allocator_t * allocator,
rcl_network_flow_endpoint_array_t * network_flow_endpoint_array)
Expand All @@ -95,13 +97,15 @@ rcl_subscription_get_network_flow_endpoint(
return RCL_RET_INVALID_ARGUMENT;
}

rcl_ret_t rcl_ret = __validate_allocator_and_network_flow_endpoint_array(allocator, network_flow_endpoint_array);
rcl_ret_t rcl_ret = __validate_allocator_and_network_flow_endpoint_array(
allocator,
network_flow_endpoint_array);
if (rcl_ret != RCL_RET_OK) {
return rcl_ret;
}

rmw_error_string_t error_string;
rmw_ret_t rmw_ret = rmw_subscription_get_network_flow_endpoint(
rmw_ret_t rmw_ret = rmw_subscription_get_network_flow_endpoints(
rcl_subscription_get_rmw_handle(subscription),
allocator,
network_flow_endpoint_array);
Expand Down
39 changes: 23 additions & 16 deletions rcl/test/rcl/test_network_flow_endpoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ TEST_F(
rcl_ret_t ret;
rcl_allocator_t allocator = rcl_get_default_allocator();
rcl_allocator_t failing_allocator = get_failing_allocator();
rcl_network_flow_endpoint_array_t network_flow_endpoint_array = rcl_get_zero_initialized_network_flow_endpoint_array();
rcl_network_flow_endpoint_array_t network_flow_endpoint_array =
rcl_get_zero_initialized_network_flow_endpoint_array();

// Invalid publisher
ret = rcl_publisher_get_network_flow_endpoints(
Expand All @@ -222,39 +223,43 @@ TEST_F(

// Invalid allocator
ret = rcl_publisher_get_network_flow_endpoints(
&this->publisher, nullptr, &network_flow_endpoint_array);
&this->publisher_1, nullptr, &network_flow_endpoint_array);
EXPECT_EQ(ret == RCL_RET_INVALID_ARGUMENT || ret == RCL_RET_UNSUPPORTED, true);
rcl_reset_error();

// Invalid network_flow_endpoint_array
ret = rcl_publisher_get_network_flow_endpoints(
&this->publisher, &allocator, nullptr);
&this->publisher_1, &allocator, nullptr);
EXPECT_EQ(ret == RCL_RET_INVALID_ARGUMENT || ret == RCL_RET_UNSUPPORTED, true);
rcl_reset_error();

// Failing allocator
set_failing_allocator_is_failing(failing_allocator, true);
ret = rcl_publisher_get_network_flow_endpoints(
&this->publisher, &failing_allocator, &network_flow_endpoint_array);
&this->publisher_1, &failing_allocator, &network_flow_endpoint_array);
EXPECT_EQ(ret == RCL_RET_BAD_ALLOC || ret == RCL_RET_UNSUPPORTED, true);
rcl_reset_error();

// Non-zero network_flow_endpoint_array
network_flow_endpoint_array.size = 1;
ret = rcl_publisher_get_network_flow_endpoints(
&this->publisher, &allocator, &network_flow_endpoint_array);
&this->publisher_1, &allocator, &network_flow_endpoint_array);
EXPECT_EQ(ret == RCL_RET_ERROR || ret == RCL_RET_UNSUPPORTED, true);
rcl_reset_error();
}

TEST_F(CLASSNAME(TestPublisherNetworkFlowEndpoints, RMW_IMPLEMENTATION), test_publisher_get_network_flow_endpoints) {
TEST_F(
CLASSNAME(
TestPublisherNetworkFlowEndpoints,
RMW_IMPLEMENTATION), test_publisher_get_network_flow_endpoints) {
rcl_ret_t ret_1;
rcl_ret_t ret_2;
bool flag = false;
rcl_allocator_t allocator = rcl_get_default_allocator();

// Get network flow endpoints of ordinary publisher
rcl_network_flow_endpoint_array_t network_flow_endpoint_array_1 = rcl_get_zero_initialized_network_flow_endpoint_array();
rcl_network_flow_endpoint_array_t network_flow_endpoint_array_1 =
rcl_get_zero_initialized_network_flow_endpoint_array();
ret_1 = rcl_publisher_get_network_flow_endpoints(
&this->publisher_1, &allocator, &network_flow_endpoint_array_1);
if (ret_1 == RCL_RET_OK || ret_1 == RCL_RET_UNSUPPORTED) {
Expand All @@ -269,7 +274,7 @@ TEST_F(CLASSNAME(TestPublisherNetworkFlowEndpoints, RMW_IMPLEMENTATION), test_pu
if (rcl_publisher_is_valid(&this->publisher_2)) {
rcl_network_flow_endpoint_array_t network_flow_endpoint_array_2 =
rcl_get_zero_initialized_network_flow_endpoint_array();
ret_2 = rcl_publisher_get_network_flow(
ret_2 = rcl_publisher_get_network_flow_endpoints(
&this->publisher_2, &allocator, &network_flow_endpoint_array_2);
if (ret_2 == RCL_RET_OK || ret_2 == RCL_RET_UNSUPPORTED) {
flag = true;
Expand Down Expand Up @@ -319,7 +324,8 @@ TEST_F(
rcl_ret_t ret;
rcl_allocator_t allocator = rcl_get_default_allocator();
rcl_allocator_t failing_allocator = get_failing_allocator();
rcl_network_flow_endpoint_array_t network_flow_endpoint_array = rcl_get_zero_initialized_network_flow_endpoint_array();
rcl_network_flow_endpoint_array_t network_flow_endpoint_array =
rcl_get_zero_initialized_network_flow_endpoint_array();

// Invalid subscription
ret = rcl_subscription_get_network_flow_endpoints(
Expand All @@ -329,27 +335,27 @@ TEST_F(

// Invalid allocator
ret = rcl_subscription_get_network_flow_endpoints(
&this->subscription, nullptr, &network_flow_endpoint_array);
&this->subscription_1, nullptr, &network_flow_endpoint_array);
EXPECT_EQ(ret == RCL_RET_INVALID_ARGUMENT || ret == RCL_RET_UNSUPPORTED, true);
rcl_reset_error();

// Invalid network_flow_endpoint_array
ret = rcl_subscription_get_network_flow_endpoints(
&this->subscription, &allocator, nullptr);
&this->subscription_1, &allocator, nullptr);
EXPECT_EQ(ret == RCL_RET_INVALID_ARGUMENT || ret == RCL_RET_UNSUPPORTED, true);
rcl_reset_error();

// Failing allocator
set_failing_allocator_is_failing(failing_allocator, true);
ret = rcl_subscription_get_network_flow_endpoints(
&this->subscription, &failing_allocator, &network_flow_endpoint_array);
&this->subscription_1, &failing_allocator, &network_flow_endpoint_array);
EXPECT_EQ(ret == RCL_RET_BAD_ALLOC || ret == RCL_RET_UNSUPPORTED, true);
rcl_reset_error();

// Non-zero network_flow_endpoint_array
network_flow_endpoint_array.size = 1;
ret = rcl_subscription_get_network_flow_endpoints(
&this->subscription, &allocator, &network_flow_endpoint_array);
&this->subscription_1, &allocator, &network_flow_endpoint_array);
EXPECT_EQ(ret == RCL_RET_ERROR || ret == RCL_RET_UNSUPPORTED, true);
rcl_reset_error();
}
Expand All @@ -364,9 +370,10 @@ TEST_F(
rcl_allocator_t allocator = rcl_get_default_allocator();

// Get network flow endpoints of ordinary subscription
rcl_network_flow_endpoint_array_t network_flow_endpoint_array_1 = rcl_get_zero_initialized_network_flow_endpoint_array();
rcl_network_flow_endpoint_array_t network_flow_endpoint_array_1 =
rcl_get_zero_initialized_network_flow_endpoint_array();
ret_1 = rcl_subscription_get_network_flow_endpoints(
&this->subscription, &allocator, &network_flow_endpoint_array_1);
&this->subscription_1, &allocator, &network_flow_endpoint_array_1);
if (ret_1 == RCL_RET_OK || ret_1 == RCL_RET_UNSUPPORTED) {
flag = true;
}
Expand All @@ -379,7 +386,7 @@ TEST_F(
if (rcl_subscription_is_valid(&this->subscription_2)) {
rcl_network_flow_endpoint_array_t network_flow_endpoint_array_2 =
rcl_get_zero_initialized_network_flow_endpoint_array();
ret_2 = rcl_subscription_get_network_flow(
ret_2 = rcl_subscription_get_network_flow_endpoints(
&this->subscription_2, &allocator, &network_flow_endpoint_array_2);
if (ret_2 == RCL_RET_OK || ret_2 == RCL_RET_UNSUPPORTED) {
flag = true;
Expand Down

0 comments on commit e08a87b

Please sign in to comment.