Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split bug fix #206

Merged
merged 5 commits into from Feb 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion src/split.c
Expand Up @@ -100,7 +100,6 @@ rcutils_split(
// take care of trailing token
if (rhs - lhs < 1) {
--string_array->size;
allocator.deallocate(string_array->data[string_array->size], allocator.state);
string_array->data[string_array->size] = NULL;
} else {
string_array->data[token_counter] =
Expand Down
7 changes: 7 additions & 0 deletions test/test_split.cpp
Expand Up @@ -128,6 +128,13 @@ TEST(test_split, split) {
EXPECT_STREQ("world", tokens10.data[2]);
ret = rcutils_string_array_fini(&tokens10);
ASSERT_EQ(RCUTILS_RET_OK, ret);

rcutils_string_array_t tokens11 = test_split("///my//hello//world/////", '/', 3);
EXPECT_STREQ("my", tokens11.data[0]);
Blast545 marked this conversation as resolved.
Show resolved Hide resolved
EXPECT_STREQ("hello", tokens11.data[1]);
EXPECT_STREQ("world", tokens11.data[2]);
ret = rcutils_string_array_fini(&tokens11);
ASSERT_EQ(RCUTILS_RET_OK, ret);
}

TEST(test_split, split_last) {
Expand Down