Skip to content

feat: add NormalizingWhiteSpace() to compare strings with collapsed whitespace - #1842

Merged
vbreuss merged 1 commit into
mainfrom
feat/normalizing-whitespace
Oct 16, 2026
Merged

vbreuss merged 1 commit into
mainfrom
feat/normalizing-whitespace

Conversation

@vbreuss

@vbreuss vbreuss commented Oct 16, 2026

Copy link
Copy Markdown
Member

The string options covered whitespace at the edges, the indentation and the newline style, but not whitespace inside a line, so comparing generated SQL, HTML or log output failed on double spaces, tabs or a different line layout. NormalizingWhiteSpace() collapses every run of Unicode whitespace, including line breaks, to a single space and trims both ends, on the subject and the expected value, and is available wherever the other string options are.

  • it supersedes IgnoringIndentation(), IgnoringNewlineStyle(), IgnoringLeadingWhiteSpace() and IgnoringTrailingWhiteSpace(), which can still be combined with it; like them it can be specified only once and cannot be combined with AsBlock()
  • wildcard and regex patterns are normalized as well; a prefix, suffix or substring keeps the whitespace at its inner end, which then has to match whitespace in the subject unless that end reaches the end of the subject
  • a failure shows the normalized values and the position of the first mismatch refers to them, as collapsed whitespace cannot be mapped back to the original lines and columns; the original subject is listed below, and no line differences are listed

… whitespace

The string options covered whitespace at the edges, the indentation and the newline style, but not whitespace inside a line, so comparing generated SQL, HTML or log output failed on double spaces, tabs or a different line layout. `NormalizingWhiteSpace()` collapses every run of Unicode whitespace, including line breaks, to a single space and trims both ends, on the subject and the expected value, and is available wherever the other string options are.

- it supersedes `IgnoringIndentation()`, `IgnoringNewlineStyle()`, `IgnoringLeadingWhiteSpace()` and `IgnoringTrailingWhiteSpace()`, which can still be combined with it; like them it can be specified only once and cannot be combined with `AsBlock()`
- wildcard and regex patterns are normalized as well; a prefix, suffix or substring keeps the whitespace at its inner end, which then has to match whitespace in the subject unless that end reaches the end of the subject
- a failure shows the normalized values and the position of the first mismatch refers to them, as collapsed whitespace cannot be mapped back to the original lines and columns; the original subject is listed below, and no line differences are listed

The build scope is set to `CoreOnly`, because the option lives in aweXpect.Core and the aweXpect tests and docs use it.
@vbreuss vbreuss self-assigned this Oct 16, 2026
@vbreuss
vbreuss enabled auto-merge (squash) October 16, 2026 15:26
@sonarqubecloud

Copy link
Copy Markdown

@vbreuss
vbreuss disabled auto-merge October 16, 2026 15:36
@vbreuss
vbreuss merged commit 083feaf into main Oct 16, 2026
14 checks passed
@vbreuss
vbreuss deleted the feat/normalizing-whitespace branch October 16, 2026 15:37
@github-actions

Copy link
Copy Markdown
Contributor

This is addressed in release v3.4.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant