@@ -526,17 +526,17 @@ private static void Test<T>(Random rng, ReadOnlySpan<T> haystackRandom, ReadOnly
526
526
527
527
if ( expectedIndex != indexOfAnyIndex )
528
528
{
529
- AssertionFailed ( haystack , needle , expectedIndex , indexOfAnyIndex , nameof ( indexOfAny ) ) ;
529
+ AssertionFailed ( haystack , needle , searchValuesInstance , expectedIndex , indexOfAnyIndex , nameof ( indexOfAny ) ) ;
530
530
}
531
531
532
532
if ( expectedIndex != searchValuesIndex )
533
533
{
534
- AssertionFailed ( haystack , needle , expectedIndex , searchValuesIndex , nameof ( searchValues ) ) ;
534
+ AssertionFailed ( haystack , needle , searchValuesInstance , expectedIndex , searchValuesIndex , nameof ( searchValues ) ) ;
535
535
}
536
536
537
537
if ( ( expectedIndex >= 0 ) != searchValuesContainsResult )
538
538
{
539
- AssertionFailed ( haystack , needle , expectedIndex , searchValuesContainsResult ? 0 : - 1 , nameof ( searchValuesContainsResult ) ) ;
539
+ AssertionFailed ( haystack , needle , searchValuesInstance , expectedIndex , searchValuesContainsResult ? 0 : - 1 , nameof ( searchValuesContainsResult ) ) ;
540
540
}
541
541
}
542
542
@@ -546,13 +546,16 @@ private static ReadOnlySpan<T> GetRandomSlice<T>(Random rng, ReadOnlySpan<T> spa
546
546
return slice . Slice ( 0 , Math . Min ( slice . Length , rng . Next ( maxLength + 1 ) ) ) ;
547
547
}
548
548
549
- private static void AssertionFailed < T > ( ReadOnlySpan < T > haystack , ReadOnlySpan < T > needle , int expected , int actual , string approach )
549
+ private static void AssertionFailed < T > ( ReadOnlySpan < T > haystack , ReadOnlySpan < T > needle , SearchValues < T > searchValues , int expected , int actual , string approach )
550
550
where T : INumber < T >
551
551
{
552
+ Type implType = searchValues . GetType ( ) ;
553
+ string impl = $ "{ implType . Name } [{ string . Join ( ", " , implType . GenericTypeArguments . Select ( t => t . Name ) ) } ]";
554
+
552
555
string readableHaystack = string . Join ( ", " , haystack . ToArray ( ) . Select ( c => int . CreateChecked ( c ) ) ) ;
553
556
string readableNeedle = string . Join ( ", " , needle . ToArray ( ) . Select ( c => int . CreateChecked ( c ) ) ) ;
554
557
555
- Assert . Fail ( $ "Expected { expected } , got { approach } ={ actual } for needle='{ readableNeedle } ', haystack='{ readableHaystack } '") ;
558
+ Assert . Fail ( $ "Expected { expected } , got { approach } ={ actual } for impl=' { impl } ', needle='{ readableNeedle } ', haystack='{ readableHaystack } '") ;
556
559
}
557
560
}
558
561
}
0 commit comments