-
Notifications
You must be signed in to change notification settings - Fork 247
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
TEST_ASSERT_EQUAL_MEMORY_ARRAY gives false negative #817
Comments
The problem is the two sizeof operators. You have the length of each array... but what you want is the number of elements and the length of each ELEMENT of the array. Because you're working with just bytes here, it could be even easier to use TEST_ASSERT_EQUAL_HEX8_ARRAY, which only takes the length to compare. |
Got it, so it should be:
|
You can either change to this:
Notice that the first sizeof is taking the size of ONE ELEMENT. The second is the number of elements in the arrays. because you're working with an array of bytes, this could be more simply worded:
or even more simply:
I believe either any of the above should work better. |
And here are the docs you requested: https://github.com/ThrowTheSwitch/Unity/blob/master/docs/UnityAssertionsReference.md#test_assert_equal_memory_array-expected-actual-len-num_elements |
Thanks for the link, I've seen those docs before, but again, there isn't any reference to what types the parameters should be, so it's a bit of guesswork. I would expect a macro to be something like this:
This would make it obvious what the parameters are. Thanks. |
Ubuntu jammy
test_notAwesome.c
ceedling test:all
There is not much in terms of documentation for the types of parameters to tests. Is this really a false negative, or am I doing something wrong?
The text was updated successfully, but these errors were encountered: