Skip to content

Commit 70fd695

Browse files
committed
Print type of SearchValues<string> on fuzzer failure
1 parent 8b8ab2d commit 70fd695

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/libraries/Fuzzing/DotnetFuzzing/Fuzzers/SearchValuesStringFuzzer.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ private static void Test(ReadOnlySpan<char> haystack, ReadOnlySpan<char> haystac
3636
SearchValues<string> searchValues = SearchValues.Create(needles, comparisonType);
3737

3838
int index = haystack.IndexOfAny(searchValues);
39-
Assert.Equal(index, haystackCopy.IndexOfAny(searchValues));
40-
Assert.Equal(index, IndexOfAnyReferenceImpl(haystack, needles, comparisonType));
39+
AssertEqual(index, haystackCopy.IndexOfAny(searchValues), searchValues);
40+
AssertEqual(index, IndexOfAnyReferenceImpl(haystack, needles, comparisonType), searchValues);
4141
}
4242

4343
private static int IndexOfAnyReferenceImpl(ReadOnlySpan<char> haystack, string[] needles, StringComparison comparisonType)
@@ -55,4 +55,15 @@ private static int IndexOfAnyReferenceImpl(ReadOnlySpan<char> haystack, string[]
5555

5656
return minIndex == int.MaxValue ? -1 : minIndex;
5757
}
58+
59+
private static void AssertEqual(int expected, int actual, SearchValues<string> searchValues)
60+
{
61+
if (expected != actual)
62+
{
63+
Type implType = searchValues.GetType();
64+
string impl = $"{implType.Name} [{string.Join(", ", implType.GenericTypeArguments.Select(t => t.Name))}]";
65+
66+
throw new Exception($"Expected {expected}, got {actual} for impl='{impl}'");
67+
}
68+
}
5869
}

0 commit comments

Comments
 (0)