-
Notifications
You must be signed in to change notification settings - Fork 17
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 routines to compare measurements against reference #167
base: main
Are you sure you want to change the base?
Conversation
I can't figure out the lint error; I'm unsure how to fix it. |
I suggest giving a go at: goimports -local "github.com/veraison/corim" -w . |
Thanks, @thomas-fossati; that helped to fix it. As Dionna suggested in the meeting, the fix needed a new line between "fmt" and the following line. I'm working on the test coverage and will post a new revision of the changes shortly. Thank you! |
81e77c4
to
23a1fb7
Compare
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.
As a general note, it's weird for Compare()
method to raise an error. Two values not being equal is not automatically considered an error condition. Also, I would expect a method called "Compare" to do a relative comparison, rather than equality test.
I would rename the method to Equal
and have it return a bool
instead.
(Alternatively, you could keep it as "Compare" and have it return an int
, with 1
indicating o > r
, -1
indicating r > o
, and 0
indicating o == r
; however, that would require chainging the implementations as well, and would require for all types in question to have partial ordering, which I don't think we want.)
Do you use vim or VS Code? If so, the popular go plugins (e.g., vim-go) should automatically update the import statements order transparently. |
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 agree with @setrofim high-level comment.
I think we should have:
- a
Compare
method for types for which ordering makes sense, e.g., SVNs -- and it should return -1,0,1 rather than error; - an
Equal
method for types for which we are only concerned about strict equality (e.g., digests) -- and this could return a bool.
I think we should have |
WFM |
I also prefer a boolean return value. If we cannot perform the comparison due to an error, should we log it and return false for a result?
It's not always equality; the type governs the semantics of comparison. In the SVN type, for example, the comparison should be equality for the ExactValueType and greater-than-or-equal for MinValueType. |
OK, I'll push a PR with recommended changes. Thanks @thomas-fossati & @setrofim for the review. |
- refactor Version type into a separate file - add a method to test if a Version type equals a reference Signed-off-by: Jagannathan Raman <[email protected]>
1695f74
to
4b374fc
Compare
Add methods to test SVN against a reference for equality. Also add a Compare method for TaggedMinSVN Signed-off-by: Jagannathan Raman <[email protected]>
Add a method to test if Digests are equal to reference values Signed-off-by: Jagannathan Raman <[email protected]>
Add a method to test if a FlagsMap type equals a reference Signed-off-by: Jagannathan Raman <[email protected]>
Add a method to test if a RawValue type equals a reference Signed-off-by: Jagannathan Raman <[email protected]>
Add a method to test if a MACaddr type equals a reference Signed-off-by: Jagannathan Raman <[email protected]>
Add a routine to compare IntegrityRegisters against a reference Signed-off-by: Jagannathan Raman <[email protected]>
4b374fc
to
03b633e
Compare
@thomas-fossati @setrofim could you please confirm if the PR looks good? Thanks! |
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.
Looks good, thanks @jraman567 !
There's one point to discuss about what to do with RawValue
.
Adds a compare routine to some of the measurement types.