Skip to content

Report mismatch segment for strings of unequal lengths#915

Merged
dennisdoomen merged 8 commits intofluentassertions:masterfrom
krajek:location_of_difference_for_strings_with_different_length
Sep 20, 2018
Merged

Report mismatch segment for strings of unequal lengths#915
dennisdoomen merged 8 commits intofluentassertions:masterfrom
krajek:location_of_difference_for_strings_with_different_length

Conversation

@krajek
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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?

@dennisdoomen dennisdoomen requested a review from jnyrup September 19, 2018 04:23
@dennisdoomen
Copy link
Copy Markdown
Member

@krajek can we merge this?

@krajek
Copy link
Copy Markdown
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
Copy Markdown
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