From 8b7ffa9ad4d84993183726c9eff3ef8c3f12d832 Mon Sep 17 00:00:00 2001 From: Levi Broderick Date: Wed, 17 Apr 2019 19:35:56 -0700 Subject: [PATCH] Add extra tests for UTF-16 validation of random 8-char data (dotnet/corefx#36903) Commit migrated from https://github.com/dotnet/corefx/commit/60aee3575e21af1070e7b834905d1864a401828d --- .../Unicode/Utf16UtilityTests.ValidateChars.netcoreapp.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libraries/System.Runtime/tests/System/Text/Unicode/Utf16UtilityTests.ValidateChars.netcoreapp.cs b/src/libraries/System.Runtime/tests/System/Text/Unicode/Utf16UtilityTests.ValidateChars.netcoreapp.cs index fd87b57..510a22c 100644 --- a/src/libraries/System.Runtime/tests/System/Text/Unicode/Utf16UtilityTests.ValidateChars.netcoreapp.cs +++ b/src/libraries/System.Runtime/tests/System/Text/Unicode/Utf16UtilityTests.ValidateChars.netcoreapp.cs @@ -51,6 +51,18 @@ namespace System.Text.Unicode.Tests GetIndexOfFirstInvalidUtf16Sequence_Test_Core(unprocessedInput, idxOfFirstInvalidChar, expectedRuneCount, expectedUtf8ByteCount); } + [Theory] // chars below presented as hex since Xunit doesn't like invalid UTF-16 string literals + [InlineData("<2BB4><218C><1BC0><613F>", 6, 6, 18)] + [InlineData("<1854><012C><4797><41D0><5464>", 4, 4, 11)] + [InlineData("<8BD3><5037><3E3A><6336>", 4, 4, 12)] + [InlineData("<0F25><7352><4025><0B93><4107>", 2, 2, 6)] + [InlineData("<2BB4><218C><1BC0><613F>", 6, 6, 18)] + [InlineData("<887C><012C><4797><41D0><5464>", 4, 4, 11)] + public void GetIndexOfFirstInvalidUtf16Sequence_WithEightRandomCharsContainingUnpairedSurrogates(string unprocessedInput, int idxOfFirstInvalidChar, int expectedRuneCount, int expectedUtf8ByteCount) + { + GetIndexOfFirstInvalidUtf16Sequence_Test_Core(unprocessedInput, idxOfFirstInvalidChar, expectedRuneCount, expectedUtf8ByteCount); + } + [Fact] public void GetIndexOfFirstInvalidUtf16Sequence_WithInvalidSurrogateSequences() { -- 2.7.4