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

Message and Field Equality Functions #116

Open
krishishah opened this issue Jul 28, 2021 · 1 comment
Open

Message and Field Equality Functions #116

krishishah opened this issue Jul 28, 2021 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@krishishah
Copy link
Contributor

For testing purposes it'd be really valuable to have message and field equality functions.

Currently, in order to check whether two messages are equal, we are forced to manually assert on every field (including nil ones) to ensure that every value is equal.

It would be great to have equality functions for messages that recursively check that fields and subfields are either nil or have equal values.

The same should be possible on a field / subfield level as well. This likely requires us to extend the field.Field interface to have an Equal(Field) bool function as well.

For the Message object, we could either add on a Equal(m *Message) bool method onto the *Message receiver or add on a utility function along the lines of: func Equal(x *Message, y *Message) bool

@krishishah
Copy link
Contributor Author

Looks like implementing T Equal(T) bool would make objects compatible with: https://pkg.go.dev/github.com/google/go-cmp/cmp#Equal

@alovak alovak added enhancement New feature or request help wanted Extra attention is needed labels Jul 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants