fix: correct error message for prefix/suffix of empty strings#791
fix: correct error message for prefix/suffix of empty strings#791
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes error message formatting for string prefix and suffix assertions when dealing with empty strings. The changes ensure that empty strings are properly handled in error messages to avoid displaying confusing contextual information.
- Updates error message logic to use
string.IsNullOrEmpty()instead of null-only checks - Adds conditional context display to prevent showing "Actual" context for null/whitespace strings
- Includes test coverage for empty string scenarios in both StartsWith and EndsWith assertions
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
ThatString.StartsWith.Tests.cs |
Adds test case for empty string input to verify proper error message formatting |
ThatString.EndsWith.Tests.cs |
Adds test case for empty string input to verify proper error message formatting |
ThatString.IsEqualTo.cs |
Conditionally adds "Actual" context only for non-null/non-whitespace strings |
StringEqualityOptions.SuffixMatchType.cs |
Updates null check to include empty strings for better error message handling |
StringEqualityOptions.PrefixMatchType.cs |
Updates null check to include empty strings for better error message handling |
🚀 Benchmark ResultsDetails
|
👽 Mutation ResultsaweXpectDetails
The final mutation score is 92.86%Coverage Thresholds: high:80 low:60 break:0aweXpect.CoreDetails
The final mutation score is 77.24%Coverage Thresholds: high:80 low:60 break:0 |
|
Test Results 14 files - 24 14 suites - 24 5m 21s ⏱️ + 1m 8s Results for commit 5774d8e. ± Comparison against base commit 07fdc9d. This pull request removes 1561 and adds 1536 tests. Note that renamed tests count towards both. |
…uffix of empty strings (#791) by Valentin Breuß
…uffix of empty strings (#791) by Valentin Breuß
|
This is addressed in release v2.25.0. |

This PR fixes error message formatting for string prefix and suffix assertions when dealing with empty strings. The changes ensure that empty strings are properly handled in error messages to avoid displaying confusing contextual information.
Key changes:
string.IsNullOrEmpty()instead of null-only checks