Merge pull request #329 from ros2/hidmic/fix-empty-action-name

Makes rcl_action_get_*_name() functions check for empty action names.
This commit is contained in:
Michel Hidalgo 2018-11-16 16:11:28 -03:00 committed by GitHub
commit e59c14638d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 74 additions and 23 deletions

View file

@ -48,18 +48,21 @@ protected:
TEST_P(TestActionDerivedName, validate_action_derived_getter)
{
rcl_ret_t ret;
char dummy_char;
char * action_derived_name;
rcl_allocator_t default_allocator =
rcl_get_default_allocator();
rcl_allocator_t default_allocator = rcl_get_default_allocator();
char * action_derived_name = NULL;
const char * const null_action_name = NULL;
rcl_ret_t ret = test_subject.get_action_derived_name(
null_action_name, default_allocator,
&action_derived_name);
EXPECT_EQ(RCL_RET_INVALID_ARGUMENT, ret);
action_derived_name = NULL;
const char * const invalid_action_name = NULL;
const char * const invalid_action_name = "";
ret = test_subject.get_action_derived_name(
invalid_action_name, default_allocator,
&action_derived_name);
EXPECT_EQ(RCL_RET_INVALID_ARGUMENT, ret);
EXPECT_EQ(RCL_RET_ACTION_NAME_INVALID, ret);
action_derived_name = NULL;
rcl_allocator_t invalid_allocator =
@ -76,6 +79,7 @@ TEST_P(TestActionDerivedName, validate_action_derived_getter)
invalid_ptr_to_action_derived_name);
EXPECT_EQ(RCL_RET_INVALID_ARGUMENT, ret);
char dummy_char = '\0';
action_derived_name = &dummy_char;
ret = test_subject.get_action_derived_name(
test_subject.action_name, default_allocator,