-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
assert: Remove the struct type constraint on 'TestEqualExportedValues' to support pointer comparisons #1384
Conversation
334a6f4
to
141f1f6
Compare
Ping @boyan-soubachov This will improve the user experience for |
Ping @boyan-soubachov Currently the library is usable, but it gives this error when comparing Protobuf objects because you have to access the underlying pointer, otherwise the comparison is false:
|
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 am also getting rid of the duplicated
ObjectsExportedFieldsAreEqual
While this looks sane, this is not that easy. We have to preserve the API surface. Please keep the function and mark it as // Deprecated:
.
382bc75
to
fc8b99a
Compare
@dolmen Done, I have update the code! 🤗 |
👀 |
@dolmen Hi, did you have time to take another look at this? |
Hi @dolmen @boyan-soubachov, did you have a chance to take a look at this? |
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, thank you
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 open a separate MR to deprecate ObjectsExportedFieldsAreEqual
, and move that change there.
Also cleanup commits, and rebase (do not merge master into your branch!).
…of duplicate 'ObjectsExportedFieldsAreEqual'
7c6d829
to
f952a8a
Compare
@dolmen Done! |
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.
Ready for v1.9.0: this is a behaviour change that require a minor release.
@dolmen Any update on when 1.9.0 is expected? Let's merge this in the meantime? |
Ping @dolmen |
I think #1517 fully implemented this. |
Pointer comparisons are supported already, just as long as the are not the top-level element. Logically, if two item or sub-items have different unexported field, then they cannot have the same underlying address. With this change, the top-level will be treated no differently from the rest of the struct fields which also makes the logic simpler.
The normal use case here is when asserting any response data that has a pointer type. As the code currently stands on
master
, you have get the underlying values and compare those instead, otherwise it fails:I'm adding a test case that would have failed with the old logic.
I am also getting rid of the duplicated
ObjectsExportedFieldsAreEqual
. Since each assert function return a boolean result, we can achieve exactly the same without the extra function. This was discussed when adding the original code (#1309 (comment)), which made sense then but now I think the time is right to remove it.