Skip to content
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

ArrayComparator#assertEquals(), canonicalizing stops it from comparing array keys #77

Closed
ghost opened this issue Dec 23, 2019 · 3 comments

Comments

@ghost
Copy link

ghost commented Dec 23, 2019

When using the canonicalize option both expected and actual arrays get sorted, and keys are removed, which causes comparison to be ok even if keys were not equal.

If canonicalize is set to false, comparison fails if keys are not equal.

image

@teohhanhui
Copy link

Arrays are equal if they contain the same key-value pairs.

* Arrays are equal if they contain the same key-value pairs.

So it seems like sort must not be used to canonicalize arrays.

@ghost
Copy link
Author

ghost commented Dec 26, 2019

Maybe using ksort to sort by key? Problem is there's only 1 test that checks canonicalized arrays, and it fails if using ksort.

image

@mgleska
Copy link
Contributor

mgleska commented Aug 12, 2024

This issue is solved by issue #112 and PR #113.

SnakeCharm3r pushed a commit to SnakeCharm3r/comparator that referenced this issue Dec 2, 2024
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

No branches or pull requests

3 participants