-
Notifications
You must be signed in to change notification settings - Fork 126
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
Cpp tests #64
Conversation
template<std::size_t SIZE> | ||
void test_array_bool(std::array<bool, SIZE> * dst_array) | ||
{ | ||
int i; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please declare the variable in the smallest scope possible (https://github.com/ros2/ros2/wiki/Developer-Guide#programming-conventions). In this case within the for loop.
Same below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
This is ready for review. Added tests for the following types:
|
|
||
/** | ||
* Helper function to generate a test pattern for boolean type. | ||
* Alternating true (even index) and false (odd index) pattern. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're doing Doxygen-style comments, can you \param
tags for each parameter
* \param[in] container (comment about parameter...)
* \param[in] size (comment about parameter...
Applies below too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added Doxygen comments.
Good stuff overall, especially the random pattern generation (I think the fancy word for that is "fuzz testing") and using the MAX and MIN values for datatypes. I'll probably incorporate that into my tests for freertps serialization on my next pass of that. My major feedback about this PR is what I said about consolidating the code with templates. Feel free to email me if you want more direction on how to do that. |
@jacquelinekay thanks for your comments. I'll be addressing them soon. |
@ernestmc So sorry for leading you down the wrong path--I looked a bit closer at the code and realized I should have said for you to use macros, not templates. Check out this commit, to branch If you think you understand that example, go ahead and try simplifying the rest of this test case with macros. Otherwise let me know and I can answer your questions, or finish it in that branch. |
@dirk-thomas or someone else may have strong feelings about where those testing macros are defined--usually macros should go in a separate header file, or at the top of the file. |
Thanks @jacquelinekay ! I managed to templatize the test pattern generator functions using type traits, so now one function name works for all. Now I'll write the macros following your model. The code should be much nicer now. |
Updated and putting for review. |
Looks great! I started CI jobs: If those come out ok, I think we should merge this. |
The cpplint style checker tool on Jenkins wants |
Good advice hehe. How can I add this linter so it runs when I build with ament? |
I have 2 ways of doing this locally:
|
I use
|
Interesting, I wonder why cpplint didn't run locally for you. Maybe cpplint was added to the set of linters for this package recently and you need to rebase against master? @dirk-thomas would you like Ernesto to squash this? I think it's ready to merge. |
ah, my bad, I didn't look at the status of the Windows build. http://ci.ros2.org/job/ci_windows/975/ Sometimes getting aggressive with templates will cause Visual Studios to fail.
I will investigate this since I have a Windows VM set up. |
hmmm I think that could be happening because a bool type is also an integral type and both templates could be getting enabled. I'll try adding an extra check (not sure if it's possible) |
@dirk-thomas I had to add |
@esteve could you test my last changes on Windows? |
Which |
@dirk-thomas I was referring to precisely that file. I added the changes locally to test. Although lint_common is present for some reason it doesn't invoke cpplint unless I explicitly add it. |
It's because that test dependency was added to the package.xml after you branched this branch off of master, and you need to either merge or rebase on the master branch. |
@ernestmc running it now, cross your fingers! 😉 |
|
@dirk-thomas I guess I don't have the latest version of the ament_lint repo because |
@ernestmc yay, it worked! Thank you so much for your patience going through all our feedback. The current PR looks good to me and ready to be merged. Could you squash the commits and trigger a CI, just to make sure? |
😄 I sure will @esteve. Thank you guys! |
cf3c862
to
8bb45b5
Compare
Squashed and triggered CI jobs: |
I get a warning in Linux but seems to be in the gtest code: http://ci.ros2.org/job/ci_linux/906/warnings17Result/ |
@@ -34,6 +42,9 @@ | |||
#include "rosidl_generator_cpp/msg/unbounded_array_static.hpp" | |||
#include "rosidl_generator_cpp/msg/unbounded_array_unbounded.hpp" | |||
|
|||
#define TEST_VECTOR_SIZE 10 | |||
#define TEST_VECTOR_SIZE_2 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constant name is not very helpful. Is this the vector size for nested messages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the first one is the size of the primitives array and the second one is the size of nested message array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about calling it TEST_NESTED_VECTOR_SIZE
then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it to something more meaningful.
The warning seems to point to an empty line |
@dirk-thomas according to this:
Maybe we can exclude that warning? |
Locally disabled warnings:
|
@ernestmc 🎉 🎈 awesome! I've deleted the branch, we delete the branch of a PR after it's been merged, but sometimes we forget too :-) |
👌 |
Connects to ros2/ros2#168