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
2 changes: 1 addition & 1 deletion src/CodingAlphabet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public CodingAlphabet(int length, string alphabet, bool caseInsensitive = false)
char c = alphabet[i];
if (caseInsensitive && char.IsLetter(c))
{
char c2 = char.IsUpper(c) ? char.ToLower(c) : char.ToUpper(c);
char c2 = char.IsUpper(c) ? char.ToLowerInvariant(c) : char.ToUpperInvariant(c);
if (alphabet.Contains(c2))
{
throw new ArgumentException($"Case-sensitivity can't be selected with an alphabet that contains both cases of the same letter", nameof(caseInsensitive));
Expand Down
18 changes: 18 additions & 0 deletions test/CodingAlphabetTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class DummyAlphabet(string alphabet) : CodingAlphabet(10, alphabet, caseInsensit
{
}

class DummyAutoAlphabet(string alphabet, bool caseInsensitive) : CodingAlphabet(alphabet.Length, alphabet, caseInsensitive)
{
}

[Test]
public void Ctor_WithBothCasesOfLettersAndCaseInsensitive_ShouldThrow()
{
Expand All @@ -43,4 +47,18 @@ public void Ctor_ProperArguments_ShouldNotThrow()
{
Assert.DoesNotThrow(() => new DummyAlphabet("01234567ab"));
}

[Test]
[SetCulture("tr-TR")]
public void Ctor_ShouldNotThrow_On_Turkish_Locale_With_Lowercase_I()
{
Assert.DoesNotThrow(() => new DummyAutoAlphabet("i", true));
}

[Test]
[SetCulture("tr-TR")]
public void Ctor_ShouldNotThrow_On_Turkish_Locale_With_Uppercase_I()
{
Assert.DoesNotThrow(() => new DummyAutoAlphabet("I", true));
}
}