Skip to content

Commit

Permalink
Handle non-ASCII strings in GetNonRandomizedHashCodeOrdinalIgnoreCase (
Browse files Browse the repository at this point in the history
…#44688)

* Fix GetNonRandomizedHashCodeOrdinalIgnoreCase

* Add a test

Co-authored-by: Levi Broderick <[email protected]>
  • Loading branch information
EgorBo and GrabYourPitchforks authored Nov 21, 2020
1 parent 8a3dc16 commit eb5df0d
Show file tree
Hide file tree
Showing 4 changed files with 233 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,22 @@ public void CantAcceptDuplicateKeysFromSourceDictionary()
AssertExtensions.Throws<ArgumentException>(null, () => new Dictionary<string, int>(source, StringComparer.OrdinalIgnoreCase));
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
// https://github.com/dotnet/runtime/issues/44681
public void DictionaryOrdinalIgnoreCaseCyrillicKeys()
{
const string Lower = "абвгдеёжзийклмнопрстуфхцчшщьыъэюя";
const string Higher = "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЬЫЪЭЮЯ";

var dictionary = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);

for (int i = 0; i < Lower.Length; i++)
{
dictionary[Lower[i].ToString()] = i;
Assert.Equal(i, dictionary[Higher[i].ToString()]);
}
}

public static IEnumerable<object[]> CopyConstructorStringComparerData
{
get
Expand Down
Loading

0 comments on commit eb5df0d

Please sign in to comment.