Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ internal static int CompareStringIgnoreCase(ref char strA, int lengthA, ref char
continue;
}

return a - b;
return aUpper - bUpper;
}

//
Expand Down
17 changes: 17 additions & 0 deletions src/libraries/System.Runtime/tests/System/StringTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1960,5 +1960,22 @@ public static void EqualityTests_AsciiOptimizations()
}
}
}

[Theory]
[InlineData("a", "A", 0)]
[InlineData("A", "a", 0)]
[InlineData("Ab", "aB", 0)]
[InlineData("aB", "Ab", 0)]
[InlineData("aB", "Aa", 1)]
[InlineData("aa", "aB", -1)]
[InlineData("\u0160a", "\u0160A", 0)]
[InlineData("\u0160a", "\u0160B", -1)]
[InlineData("\u0160b", "\u0160A", 1)]
[InlineData("\u0160b\u0160\u0160\u0160", "\u0160A\u0160\u0160\u0160", 1)]
[InlineData("\u0160A\u0160\u0160\u0160", "\u0160b\u0160\u0160\u0160", -1)]
public static void TestCompareOrdinalIgnoreCase(string a, string b, int sign)
{
Assert.Equal(sign, Math.Sign(string.Compare(a, b, StringComparison.OrdinalIgnoreCase)));
}
}
}