Skip to content

Commit bead643

Browse files
committed
add test for code points with a low byte of 0xFF
1 parent 3466394 commit bead643

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

test/UnidecoderTest.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,27 @@ public void UnidecodeOnNullShouldReturnEmptyString()
7979
{
8080
Assert.Equal("", ((string)null).Unidecode());
8181
}
82-
}
82+
83+
/// <summary>
84+
/// Test that code points with the maximum low byte of 255 do not
85+
/// cause an IndexOutOfRangeException (see commit: acd8fb4)
86+
/// </summary>
87+
[Fact]
88+
public void MaximumLowByteTest()
89+
{
90+
byte low = 0xFF;
91+
for (var high = (char)0; high <= byte.MaxValue; high++)
92+
{
93+
var codePoint = (char)((high << 8) | low);
94+
try
95+
{
96+
codePoint.Unidecode();
97+
}
98+
catch (System.IndexOutOfRangeException)
99+
{
100+
Assert.True(false);
101+
}
102+
}
103+
}
104+
}
83105
}

0 commit comments

Comments
 (0)