-
Notifications
You must be signed in to change notification settings - Fork 6
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
Modifies PartialEq
for Violation
#208
Conversation
* Changes `PartialEq` for `Violation` to defer to flattened violations for equivalence rather then `Violation`s tree * Modified `flattened_violations` to return sorted vector absed on constraint * Modified `flattened_violations` to not return the violation itself when there are no children
ion-schema/src/violation.rs
Outdated
), | ||
], | ||
); | ||
assert_ne!(violation1.violations(), violation2.violations()); |
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.
question—why are we asserting that this are not equal? This seems like it's not relevant to the test.
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.
Err: this was part of debugging. I will remove this.
ion-schema/src/violation.rs
Outdated
use crate::violation::{Violation, ViolationCode}; | ||
|
||
#[test] | ||
fn violation_equivalence() { |
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.
Can you add another test case with multiple levels of nesting?
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.
Sure. I will add that.
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.
Also, if we're writing tests for eq
, we should also include cases where things are not equal and other edge cases.
constraint
not equalcode
not equalmessage
not equalion_path
not equalflattened_violations()
not equalviolations
not equal, butflattened_violations()
equalviolations
empty for bothviolations
with two child violations with the same constraint name
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.
PartialEq
had missing ion_path
equivalence check. Added a condition check for that along with more tests.
* Adds macros for asserting violation equivalence * Changes `violations` back to a vector instead of `HashSet`
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.
Two minor comments. Otherwise it looks good.
Issue #206:
Description of changes:
This PR works on fixing
PartialEq
forViolation
and modifiesflattened_violations
return sorted violations which can be used for comparison.List of changes:
PartialEq
forViolation
to defer to flattened violationsfor equivalence rather then
Violation
s treeflattened_violations
to return sorted vector absed onconstraint
flattened_violations
to not return the violation itselfwhen there are no children
Test:
Adds test for violations equivalence.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.