CharsComparer
Comparator for two Chars.
using System.Runtime.CompilerServices;
namespace NUnit.Framework.Constraints.Comparers
{
internal static class CharsComparer
{
[System.Runtime.CompilerServices.NullableContext(1)]
public static EqualMethodResult Equal(object x, object y, ref Tolerance tolerance, ComparisonState state, NUnitEqualityComparer equalityComparer)
{
if (x is char) {
char c = (char)x;
if (y is char) {
char c2 = (char)y;
if (tolerance.HasVariance)
return EqualMethodResult.ToleranceNotSupported;
bool ignoreCase = equalityComparer.IgnoreCase;
char c3 = ignoreCase ? char.ToLower(c) : c;
char c4 = ignoreCase ? char.ToLower(c2) : c2;
if (c3 != c4)
return EqualMethodResult.ComparedNotEqual;
return EqualMethodResult.ComparedEqual;
}
}
return EqualMethodResult.TypesNotSupported;
}
}
}