Skip to content

feat: improve visualization of string difference for suffix#764

Merged
vbreuss merged 4 commits intomainfrom
topic/improve-endswith-string-diff-visualization
Sep 7, 2025
Merged

feat: improve visualization of string difference for suffix#764
vbreuss merged 4 commits intomainfrom
topic/improve-endswith-string-diff-visualization

Conversation

@vbreuss
Copy link
Copy Markdown
Member

@vbreuss vbreuss commented Sep 7, 2025

This PR improves string difference visualization for suffix matching by adding proper context for prefix/suffix comparisons and enhancing string difference handling. The change makes error messages more specific about whether differences are being checked as prefixes or suffixes.

Key changes:

  • Adds new MatchType.Prefix and MatchType.Suffix enum values to distinguish different comparison modes
  • Implements suffix-specific string difference calculation that compares from the end of strings
  • Updates test expectations to show clearer error messages with "expected prefix" and "expected suffix" label

@vbreuss vbreuss self-assigned this Sep 7, 2025
Copilot AI review requested due to automatic review settings September 7, 2025 09:38
@vbreuss vbreuss added the enhancement New feature or request label Sep 7, 2025
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves string difference visualization for suffix matching by adding proper context for prefix/suffix comparisons and enhancing string difference handling. The change addresses issue #702 by making error messages more specific about whether differences are being checked as prefixes or suffixes.

  • Adds new MatchType.Prefix and MatchType.Suffix enum values to distinguish different comparison modes
  • Implements suffix-specific string difference calculation that compares from the end of strings
  • Updates test expectations to show clearer error messages with "expected prefix" and "expected suffix" labels

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
StringDifference.cs Core implementation adding suffix match type, index calculation from end, and improved visualization
StringEqualityOptions.SuffixMatchType.cs Updated to use new suffix match type for more accurate error reporting
StringEqualityOptions.PrefixMatchType.cs Updated to use new prefix match type for consistent handling
ThatString.StartsWith.cs Removed inline constraint class (likely moved to shared location)
ThatString.EndsWith.cs Removed inline constraint class (likely moved to shared location)
API test files Updated to include new enum values in public API
Test files Updated expected error messages to show "expected prefix" and "expected suffix" labels

Comment thread Source/aweXpect.Core/Core/StringDifference.cs
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Sep 7, 2025

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Sep 7, 2025

Test Results

    4 files   -     34      4 suites   - 34   17s ⏱️ - 4m 13s
1 156 tests  - 16 440  1 155 ✅  - 16 439  1 💤  - 1  0 ❌ ±0 
3 360 runs   - 46 092  3 359 ✅  - 46 091  1 💤  - 1  0 ❌ ±0 

Results for commit 5ba2f4b. ± Comparison against base commit 4dc12c1.

This pull request removes 16533 and adds 93 tests. Note that renamed tests count towards both.
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenAwaited_ShouldNotBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenAwaited_WithoutReturnValue_ShouldNotBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenNotAwaited_ShouldBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenNotAwaited_WithoutReturnValue_ShouldBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenNotAwaited_WithoutReturnValue_WithVerifyInMethod_ShouldStillBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenVerifiedStatically_ShouldNotBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenVerifiedStatically_WithoutReturnValue_ShouldNotBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenVerifiedWithStaticUsing_ShouldNotBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenVerifiedWithStaticUsing_WithoutReturnValue_ShouldNotBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenVerified_ShouldNotBeFlagged
…
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message8dcb70dd-51a8-482a-b151-f455aa48774b")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message95c37750-7a9b-48cd-9eee-fdec2de21c52")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "messageef5eb360-4930-4107-8b37-1bb43f23352c")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "message30155fb0-7a80-4cbb-8440-922ee0472d74")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "message71f30f2f-9510-4f30-982b-6176d9bc676a")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "message7b4627c3-6286-4485-95d0-8775e67bf473")
aweXpect.Core.Tests.Core.StringDifferenceTests ‑ ShouldCacheIndexOfFirstMismatch(matchType: Equality, expectedIndex: -1)
aweXpect.Core.Tests.Core.StringDifferenceTests ‑ ShouldCacheIndexOfFirstMismatch(matchType: Prefix, expectedIndex: -1)
aweXpect.Core.Tests.Core.StringDifferenceTests ‑ ShouldCacheIndexOfFirstMismatch(matchType: Regex, expectedIndex: 0)
aweXpect.Core.Tests.Core.StringDifferenceTests ‑ ShouldCacheIndexOfFirstMismatch(matchType: Suffix, expectedIndex: -1)
…

@vbreuss vbreuss merged commit f5deead into main Sep 7, 2025
14 checks passed
@vbreuss vbreuss deleted the topic/improve-endswith-string-diff-visualization branch September 7, 2025 09:55
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Sep 7, 2025

🚀 Benchmark Results

Details

BenchmarkDotNet v0.14.0, Ubuntu 24.04.3 LTS (Noble Numbat)
AMD EPYC 7763, 1 CPU, 4 logical and 2 physical cores
.NET SDK 8.0.413
[Host] : .NET 8.0.19 (8.0.1925.36514), X64 RyuJIT AVX2

Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15
LaunchCount=1 WarmupCount=10

Method Mean Error StdDev Gen0 Gen1 Allocated
Bool_aweXpect 222.2 ns 2.80 ns 2.49 ns 0.0300 - 504 B
Bool_FluentAssertions 240.5 ns 1.52 ns 1.35 ns 0.0567 - 952 B
Bool_TUnit 889.0 ns 5.64 ns 5.28 ns 0.1431 - 2408 B
Equivalency_aweXpect 305,791.9 ns 1,999.60 ns 1,870.43 ns 20.0195 0.9766 335556 B
Equivalency_FluentAssertions 2,259,553.8 ns 21,868.50 ns 20,455.81 ns 273.4375 46.8750 4584416 B
Equivalency_TUnit 708,133.1 ns 6,098.54 ns 5,704.58 ns 51.7578 2.9297 880545 B
Int_GreaterThan_aweXpect 243.4 ns 1.59 ns 1.49 ns 0.0486 - 816 B
Int_GreaterThan_FluentAssertions 251.4 ns 1.69 ns 1.58 ns 0.0730 - 1224 B
Int_GreaterThan_TUnit 1,173.8 ns 8.93 ns 7.92 ns 0.1774 - 2984 B
ItemsCount_AtLeast_aweXpect 473.7 ns 1.97 ns 1.84 ns 0.0873 - 1464 B
ItemsCount_AtLeast_FluentAssertions 468.1 ns 3.04 ns 2.54 ns 0.1197 - 2008 B
ItemsCount_AtLeast_TUnit 14,880.3 ns 140.59 ns 131.51 ns 1.6327 - 27480 B
String_aweXpect 421.9 ns 2.17 ns 1.92 ns 0.0734 - 1232 B
String_FluentAssertions 456.9 ns 2.10 ns 1.76 ns 0.1292 - 2168 B
String_TUnit 1,184.2 ns 5.04 ns 4.47 ns 0.1831 - 3072 B
StringArray_aweXpect 1,746.8 ns 4.52 ns 4.23 ns 0.1717 - 2888 B
StringArray_FluentAssertions 1,319.7 ns 24.79 ns 21.98 ns 0.2480 - 4152 B
StringArray_TUnit 3,215.6 ns 8.77 ns 8.20 ns 0.3128 - 5296 B
StringArrayInAnyOrder_aweXpect 2,274.2 ns 7.72 ns 7.22 ns 0.1831 - 3080 B
StringArrayInAnyOrder_FluentAssertions 150,260.1 ns 1,500.36 ns 1,403.44 ns 3.4180 - 63787 B
StringArrayInAnyOrder_TUnit 3,816.6 ns 12.16 ns 10.78 ns 0.3815 - 6488 B

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Sep 9, 2025

This is addressed in release v2.23.0.

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

Labels

enhancement New feature or request state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use string diff visualization also for StartsWith and EndsWith

2 participants