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

Report mismatch segment for strings of unequal lengths #915

Conversation

krajek
Copy link
Contributor

@krajek krajek commented Sep 16, 2018

Proposal to fix #907.

I used the same mechanism to display differences as in part of the code that handles strings with equal lengths, with few adjustments.

BTW Possible follow-ups:

  • "lazy" version of FailWith, that delays the calculation of message and its params
  • display differences improvement reporting line within the text when the first difference occurs, maybe only for multiline subjects

@dennisdoomen
Copy link
Member

Are you still working on this? If so, please prefix it it with [WIP]

@krajek krajek changed the title Report mismatch segment for strings of unequal lengths [WIP] Report mismatch segment for strings of unequal lengths Sep 17, 2018
@krajek
Copy link
Contributor Author

krajek commented Sep 17, 2018

I think I am done with the first proposition.
What do you think about the idea of putting a mismatching segment in the assertion message and about this particular implementation?

@krajek krajek changed the title [WIP] Report mismatch segment for strings of unequal lengths Report mismatch segment for strings of unequal lengths Sep 17, 2018
Copy link
Member

@dennisdoomen dennisdoomen left a comment

Choose a reason for hiding this comment

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

Only minor comments. Check the legend for the meaning of the emojis.

int indexOfMismatch = subject.IndexOfFirstMismatch(expected, comparisonMode);

// If there is no difference it means that subject and expected have common prefix
// and the first difference is after just that prefix.
Copy link
Member

Choose a reason for hiding this comment

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

❓ What do you mean with prefix here?

Src/FluentAssertions/Primitives/StringEqualityValidator.cs Outdated Show resolved Hide resolved
Tests/Shared.Specs/BasicEquivalencySpecs.cs Show resolved Hide resolved
@dennisdoomen
Copy link
Member

@krajek can we merge this?

@krajek
Copy link
Contributor Author

krajek commented Sep 19, 2018

Yes, please. Thanks for the reviews.
After this one is merged I will try to follow up will lazy FailWith and refactor accordingly.

@dennisdoomen dennisdoomen merged commit c6e72d6 into fluentassertions:master Sep 20, 2018
@dennisdoomen
Copy link
Member

Awesome. Thanks man.

@krajek krajek deleted the location_of_difference_for_strings_with_different_length branch September 20, 2018 13:09
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.

Show location of difference when comparing two strings
3 participants