IntelliTect / IntelliTect/TestTools.Console

ConsoleAssert.GetMessageText has its own inline char-by-char diff that duplicates WildcardMatchAnalyzer.FindMismatchPosition

Open
#130 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1
Forks
0
Avg merge
2m
Merged PRs (30d)
5

Description

## Problem

\GetMessageText\ in \ConsoleAssert.cs\ contains an inline loop that finds the first character difference between two strings:

\\\csharp
// existing loop in GetMessageText
for (int i = 0; i < Math.Min(expected.Length, actual.Length); i++)
{
if (expected[i] != actual[i]) { ... }
}
\\\

PR #104 added \WildcardMatchAnalyzer.FindMismatchPosition\ which does exactly the same thing.

## Impact

This is a minor DRY issue in pre-existing code — no functional bug. The inline loop is used for the non-wildcard mismatch message while \FindMismatchPosition\ is used for the wildcard branch. Both compute the first differing character index.

## Suggestion

Extract a shared \FindFirstMismatchIndex(string expected, string actual)\ helper (or delegate the \GetMessageText\ call to \WildcardMatchAnalyzer.FindMismatchPosition\) so the logic lives in one place.

This was identified during the PR #104 review but left out because the inline loop is pre-existing code unrelated to the wildcard feature.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.