-
Notifications
You must be signed in to change notification settings - Fork 185
fix Delta.DifferentAt behavior via changes to Path.Contains #20
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,14 +51,28 @@ func (p Path) Pop() { | |
| } | ||
| } | ||
|
|
||
| // Contains returns true if the supplied string appears within the Path | ||
| // Contains returns true if the supplied string, delimited on ".", matches | ||
| // p.parts up to the length of the supplied string. | ||
|
Comment on lines
+54
to
+55
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. femto-nit: not sure if it's your IDE or editor changing the above, but comments should have a single space (not
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it, will keep in mind for next time |
||
| // e.g. if the Path p represents "A.B": | ||
| // subject "A" -> true | ||
| // subject "A.B" -> true | ||
| // subject "A.B.C" -> false | ||
| // subject "B" -> false | ||
| // subject "A.C" -> false | ||
| func (p Path) Contains(subject string) bool { | ||
| for _, p := range p.parts { | ||
| if p == subject { | ||
| return true | ||
| subjectSplit := strings.Split(subject, ".") | ||
|
|
||
| if len(subjectSplit) > len(p.parts) { | ||
| return false | ||
| } | ||
|
|
||
| for i, s := range subjectSplit { | ||
| if p.parts[i] != s { | ||
| return false | ||
| } | ||
| } | ||
| return false | ||
|
|
||
| return true | ||
| } | ||
|
|
||
| // NewPath returns a new Path struct pointer from a dotted-notation string, | ||
|
|
||
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.
++ Super clear test cases! Love it!
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.
agreed, excellent clarity @echen-98