iso8583 icon indicating copy to clipboard operation
iso8583 copied to clipboard

Message and Field Equality Functions

Open krishishah opened this issue 4 years ago • 1 comments

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 avatar Jul 28 '21 21:07 krishishah

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

krishishah avatar Jul 28 '21 21:07 krishishah