-
Notifications
You must be signed in to change notification settings - Fork 402
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
iox-#1196 fix compiler warnings in hoofs tests #1453
iox-#1196 fix compiler warnings in hoofs tests #1453
Conversation
…ts and correct first part of cxx tests Signed-off-by: Christian Eltzschig <[email protected]>
Signed-off-by: Christian Eltzschig <[email protected]>
Signed-off-by: Christian Eltzschig <[email protected]>
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.
LGTM, left a few nitpicks.
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.
Most comments refer to issues with introducing unnecessary casts (as far as I can see) when it instead would be better to change the signedness of some iteration variable or similar.
I think the goal should be to avoid these kinds of casts as they are usually a (interface) design problem.
using AdjacencyList = iox::cxx::vector<VertexType*, DEGREE_LIMIT>; | ||
|
||
static constexpr Index_t INVALID_INDEX = -1; | ||
static constexpr Index_t INVALID_INDEX = std::numeric_limits<uint64_t>::max(); |
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.
This has logical implications if set to this maximum and should not be changed like this (as any positive integer is a valid value). I think it is better to keep the value signed. Furthermore we will never have more nodes than we can store with 32 bits (we would be out of memory first) and hence not use a 64 bit integer.
When suddenly the invalid value is positive I cannot guarantee it breaks something at the limits (which are not tested, as is the case for many classes...).
I know the graph is not used (leftover from some internals in the past) and if we will ever reuse something like this I will refactor it for more generality and performance.
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 will reduce the size to 32 but would stick with unsigned since this type is used in array operator[] and this requires an unsigned integer. So I have to write a little less static_cast
@@ -35,14 +35,14 @@ namespace | |||
{ | |||
struct Data | |||
{ | |||
Data(int id = 0, size_t count = 0) | |||
Data(uint64_t id = 0U, uint64_t count = 0) |
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.
Can be done of course but I thought in test code int
is ok? Same with size_t
, esecially if we interact with the STL (not the case here).
We have to be careful with upgrading everything to uint64_t
without considering context as this may cause other issues. Here it is 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.
But with int
and size_t
we get warnings when we compare or assign it to uint64_t
types which are returned by capacity
, size
or other functions.
iceoryx_hoofs/test/integrationtests/test_resizeable_lockfree_queue_stresstest.cpp
Outdated
Show resolved
Hide resolved
iceoryx_hoofs/test/integrationtests/test_resizeable_lockfree_queue_stresstest.cpp
Outdated
Show resolved
Hide resolved
iceoryx_hoofs/test/integrationtests/test_resizeable_lockfree_queue_stresstest.cpp
Outdated
Show resolved
Hide resolved
@@ -313,26 +313,26 @@ TEST_F(forward_list_test, NotFullWhenFilledWithCapacityAndEraseOneElements) | |||
TEST_F(forward_list_test, NotFullWhenFilledWithCapacityAndEraseOneAndReinsertElements) | |||
{ | |||
::testing::Test::RecordProperty("TEST_ID", "7df1e41e-f3c2-4ea2-9ed1-ed68a5342ce2"); | |||
uint64_t i = 0U; | |||
for (; i < sut.capacity(); ++i) | |||
int64_t counter = 0; |
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 think this counter could be uint64_t
and we would avoid all cast.
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.
actually int64_t is better since sut requires signed integers and changing the sut to unsigned is even more work
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, less changes that way. In theory the tests can be redesigned but it is not worth it.
@@ -294,20 +294,20 @@ TEST_F(list_test, NotFullWhenFilledWithCapacityAndEraseOneElements) | |||
TEST_F(list_test, NotFullWhenFilledWithCapacityAndEraseOneAndReinsertElements) | |||
{ | |||
::testing::Test::RecordProperty("TEST_ID", "c7e70ac7-e476-43aa-976c-1ac78513c869"); | |||
uint64_t i = 0U; | |||
for (; i < sut.capacity(); ++i) | |||
int64_t counter = 0U; |
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 think counter
should be unsigned to avoid the casts.
Has multiple occurrences in the following tests.
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.
Same again, the list requires signed integers and switching to unsigned requires even more work.
…make STACK_SIZE in test uint64_t again Signed-off-by: Christian Eltzschig <[email protected]>
Signed-off-by: Christian Eltzschig <[email protected]>
@elfenpiff Ubuntu is still failing:
|
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.
Only a comment out of sync but should be fixed.
iceoryx_hoofs/test/integrationtests/test_resizeable_lockfree_queue_stresstest.cpp
Outdated
Show resolved
Hide resolved
@@ -313,26 +313,26 @@ TEST_F(forward_list_test, NotFullWhenFilledWithCapacityAndEraseOneElements) | |||
TEST_F(forward_list_test, NotFullWhenFilledWithCapacityAndEraseOneAndReinsertElements) | |||
{ | |||
::testing::Test::RecordProperty("TEST_ID", "7df1e41e-f3c2-4ea2-9ed1-ed68a5342ce2"); | |||
uint64_t i = 0U; | |||
for (; i < sut.capacity(); ++i) | |||
int64_t counter = 0; |
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, less changes that way. In theory the tests can be redesigned but it is not worth it.
Signed-off-by: Christian Eltzschig <[email protected]>
ac9efd2
to
b29fd03
Compare
399bc62
to
2802cf8
Compare
Signed-off-by: Christian Eltzschig <[email protected]>
2802cf8
to
07359d8
Compare
Signed-off-by: Christian Eltzschig <[email protected]>
d41eb82
to
971d88e
Compare
Signed-off-by: Christian Eltzschig <[email protected]>
971d88e
to
6dd45cc
Compare
Codecov Report
@@ Coverage Diff @@
## master #1453 +/- ##
==========================================
+ Coverage 78.75% 78.78% +0.02%
==========================================
Files 377 377
Lines 14490 14490
Branches 2011 2011
==========================================
+ Hits 11412 11416 +4
+ Misses 2438 2437 -1
+ Partials 640 637 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Pre-Review Checklist for the PR Author
iox-#123-this-is-a-branch
)iox-#123 commit text
)git commit -s
)task-list-completed
)Notes for Reviewer
Checklist for the PR Reviewer
Post-review Checklist for the PR Author
References