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

Fix embarrassing ustring::compare(string_view) bug #2283

Merged
merged 1 commit into from
Jul 10, 2019

Conversation

lgritz
Copy link
Collaborator

@lgritz lgritz commented Jul 8, 2019

The logic was wrong in cases where the string_view was longer than the
ustring, but they has the same character sequence up to the length of
the ustring.

Add some unit tests to ferret out this case.

To do: fully flesh out unit tests for every last bit of functionality
of ustring and string_view.

@fpsunflower
Copy link
Contributor

Why not just use:

return string_view(m_chars, size()).compare(str);

which already has the correct logic?

The logic was wrong in cases where the string_view was longer than the
ustring, but they has the same character sequence up to the length of
the ustring.

Add some unit tests to ferret out this case.

To do: fully flesh out unit tests for every last bit of functionality
of ustring and string_view.
@lgritz
Copy link
Collaborator Author

lgritz commented Jul 9, 2019

I think you're right, and I can eliminate a few other cases as well. Updated.

@fpsunflower
Copy link
Contributor

LGTM!

@lgritz lgritz merged commit 998b950 into AcademySoftwareFoundation:master Jul 10, 2019
@lgritz lgritz deleted the lg-ustring branch July 10, 2019 05:46
lgritz added a commit to lgritz/OpenImageIO that referenced this pull request Jul 10, 2019
…undation#2283)

The logic was wrong in cases where the string_view was longer than the
ustring, but they has the same character sequence up to the length of
the ustring.

Add some unit tests to ferret out this case.

To do: fully flesh out unit tests for every last bit of functionality
of ustring and string_view.
lgritz added a commit to lgritz/OpenImageIO that referenced this pull request Jul 12, 2019
…undation#2283)

The logic was wrong in cases where the string_view was longer than the
ustring, but they has the same character sequence up to the length of
the ustring.

Add some unit tests to ferret out this case.

To do: fully flesh out unit tests for every last bit of functionality
of ustring and string_view.
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.

2 participants