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

Ensure that equality on unicode chars works. #4

Merged
merged 1 commit into from
Nov 18, 2016

Conversation

liquidgecka
Copy link
Owner

Unicode characters were broken as it would only compare the last byte of
the character due to the strange way that string indexing works in
golang. This converts that to a working rune iteration which is far
safer and catches errors.

A regression test was added in order to test for this case in the
future.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 2eb52e2 on equal_should_be_equal into ca1ec5a on master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 2eb52e2 on equal_should_be_equal into ca1ec5a on master.

Copy link
Collaborator

@philpennock philpennock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

for i := range hstr {
if hstr[i] != wstr[i] {
for i, r := range hrunes {
if r != wrunes[i] {
return []string{
fmt.Sprintf("%s: difference at index %d.", desc, i),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think this indexing is now a little confusing; how is it indexed? s/index/rune/?

Error message does not clearly guide the user to the correct point.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. changed.

Unicode characters were broken as it would only compare the first byte of
the character due to the strange way that string indexing works in
golang. This converts that to a working rune iteration which is far
safer and catches errors.

A regression test was added in order to test for this case in the
future.
@liquidgecka liquidgecka merged commit aa5f957 into master Nov 18, 2016
@liquidgecka liquidgecka deleted the equal_should_be_equal branch November 18, 2016 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants