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

Add comparison operators for variant_object #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sim31
Copy link
Contributor

@sim31 sim31 commented Jun 10, 2018

Useful for eosio contract unit tests, when comparing expected rows and actual. Especially when compared objects have nested objects inside them.

Copy link
Contributor

@b1bart b1bart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sim31 thank you for submitting this, sorry it took so long to review.

In addition to addressing the feedback, this new feature should have related unit tests before we can accept it.

@@ -164,6 +164,21 @@ namespace fc
}


bool operator ==( const variant_object& obj1, const variant_object& obj2 ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the order which these iterators traverse a (mutable_)?variant_object is not strictly defined as ordered. As a result this comparison will return false when comparing these two objects:

auto lhs = mutable_variant_object()("foo", 1)("bar", 1);
auto rhs = mutable_variant_object()("bar", 1)("foo", 1);

// expect are_equal to be true but it is not!
bool are_equal = (lhs == rhs); 

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

Successfully merging this pull request may close these issues.

3 participants