Skip to content

Implement equality operator function for C messages.#648

Merged
hidmic merged 4 commits intomasterfrom
hidmic/equality-operator-for-c-messages
Jan 21, 2022
Merged

Implement equality operator function for C messages.#648
hidmic merged 4 commits intomasterfrom
hidmic/equality-operator-for-c-messages

Conversation

@hidmic
Copy link
Copy Markdown
Contributor

@hidmic hidmic commented Jan 20, 2022

Precisely what the title says. While working on typesupport introspection tests, I realized that while operator== is overloaded for C++ messages, there's no such functionality for C messages. Thus a lot of code would have to be written to compare C messages for equality. This patch amends this.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
@hidmic
Copy link
Copy Markdown
Contributor Author

hidmic commented Jan 20, 2022

This is actually lacking some tests. I'll add them.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
@hidmic hidmic requested review from gbiggs and j-rivero January 20, 2022 20:42
Copy link
Copy Markdown
Member

@gbiggs gbiggs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


TEST(string_functions, equality_comparison) {
rosidl_runtime_c__String empty_string, foo_string, bar_string;
EXPECT_TRUE(rosidl_runtime_c__String__init(&empty_string));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These could be asserts to break early if initialisation fails.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that no tests in here do that to ensure rosidl_runtime_c__String__fini gets invoked. I could bring in rcpputils::scope_exit though. Thoughts?

@hidmic
Copy link
Copy Markdown
Contributor Author

hidmic commented Jan 21, 2022

CI up to rosidl_generator_c and rosidl_runtime_c (nothing uses this API just yet):

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@hidmic
Copy link
Copy Markdown
Contributor Author

hidmic commented Jan 21, 2022

Alright, going in!

@hidmic hidmic merged commit 57a7f92 into master Jan 21, 2022
@delete-merged-branch delete-merged-branch bot deleted the hidmic/equality-operator-for-c-messages branch January 21, 2022 18:48
nnmm pushed a commit to nnmm/rosidl that referenced this pull request Mar 8, 2022
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
nnmm pushed a commit to nnmm/rosidl that referenced this pull request Mar 8, 2022
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
hidmic added a commit that referenced this pull request Apr 25, 2022
* Implement equality operator function for C messages. (#648)

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>

* Implement copy function for C messages (#650)

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>

* Replace rcutils_allocator with the system allocator

Signed-off-by: Nikolai Morin <nnmmgit@gmail.com>

* Set the output size unconditionally when copying sequences

Signed-off-by: Nikolai Morin <nnmmgit@gmail.com>

Co-authored-by: Michel Hidalgo <michel@ekumenlabs.com>
hidmic added a commit that referenced this pull request Apr 25, 2022
* Implement equality operator function for C messages. (#648)

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>

* Implement copy function for C messages (#650)

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>

* Replace rcutils_allocator with the system allocator

Signed-off-by: Nikolai Morin <nnmmgit@gmail.com>

* Set the output size unconditionally when copying sequences

Signed-off-by: Nikolai Morin <nnmmgit@gmail.com>

Co-authored-by: Michel Hidalgo <michel@ekumenlabs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants