@@ -31,7 +31,7 @@ public enum TestSystemRequirements
31
31
// Add more as needed
32
32
}
33
33
34
- public class FactOnSystemRequirementAttribute : FactAttribute
34
+ private sealed class FactOnSystemRequirementAttribute : FactAttribute
35
35
{
36
36
private TestSystemRequirements RequiredSystems ;
37
37
@@ -62,7 +62,7 @@ private bool IsSystemSupported(TestSystemRequirements requiredSystems)
62
62
}
63
63
64
64
65
- public class TestIfCondition : FactAttribute
65
+ public sealed class TestIfCondition : FactAttribute
66
66
{
67
67
public TestIfCondition ( Func < bool > condition , string skipReason )
68
68
{
@@ -1034,6 +1034,7 @@ public void BruteForceTestArm64()
1034
1034
// credit: based on code from Google Fuchsia (Apache Licensed)
1035
1035
public static bool ValidateUtf8Fuschia ( byte [ ] data )
1036
1036
{
1037
+ if ( data == null ) return false ;
1037
1038
int pos = 0 ;
1038
1039
int len = data . Length ;
1039
1040
uint codePoint ;
@@ -1104,13 +1105,14 @@ private bool InvalidateUtf8(byte[] utf8, int badindex,Utf8ValidationDelegate utf
1104
1105
int utf16CodeUnitCountAdjustment , scalarCountAdjustment ;
1105
1106
byte * dotnetResult = DotnetRuntime . Utf8Utility . GetPointerToFirstInvalidByte ( pInput , utf8 . Length , out utf16CodeUnitCountAdjustment , out scalarCountAdjustment ) ;
1106
1107
int dotnetOffset = ( int ) ( dotnetResult - pInput ) ;
1108
+ var message = "Suprisingly, scalarResult != simdResult {0} != {1}, badindex = {2}, length = {3}" ;
1107
1109
if ( scalarOffset != simdOffset )
1108
1110
{
1109
- Console . WriteLine ( "Suprisingly, scalarResult != simdResult {0} != {1}, badindex = {2}, length = {3}" , scalarOffset , simdOffset , badindex , utf8 . Length ) ;
1111
+ Console . WriteLine ( message , scalarOffset , simdOffset , badindex , utf8 . Length ) ;
1110
1112
}
1111
1113
if ( dotnetOffset != simdOffset )
1112
1114
{
1113
- Console . WriteLine ( "Suprisingly, dotnetOffset != simdResult {0} != {1}, badindex = {2}, length = {3}" , dotnetOffset , simdOffset , badindex , utf8 . Length ) ;
1115
+ Console . WriteLine ( message , dotnetOffset , simdOffset , badindex , utf8 . Length ) ;
1114
1116
}
1115
1117
return ( scalarResult == simdResult ) && ( simdResult == dotnetResult ) ;
1116
1118
}
@@ -1151,7 +1153,7 @@ private bool ValidateUtf8(byte[] utf8,Utf8ValidationDelegate utf8ValidationDeleg
1151
1153
}
1152
1154
1153
1155
// Helper method to calculate the actual offset and length from a Range
1154
- private ( int offset , int length ) GetOffsetAndLength ( int totalLength , Range range )
1156
+ private static ( int offset , int length ) GetOffsetAndLength ( int totalLength , Range range )
1155
1157
{
1156
1158
var start = range . Start . GetOffset ( totalLength ) ;
1157
1159
var end = range . End . GetOffset ( totalLength ) ;
@@ -1167,6 +1169,10 @@ public bool ValidateCount(byte[] utf8, Utf8ValidationDelegate utf8ValidationDele
1167
1169
{
1168
1170
int dotnetUtf16Adjustment , dotnetScalarCountAdjustment ;
1169
1171
int simdUnicodeUtf16Adjustment , simdUnicodeScalarCountAdjustment ;
1172
+ if ( utf8 == null || utf8ValidationDelegate == null )
1173
+ {
1174
+ return false ;
1175
+ }
1170
1176
1171
1177
var isDefaultRange = range . Equals ( default ( Range ) ) ;
1172
1178
var ( offset , length ) = isDefaultRange ? ( 0 , utf8 . Length ) : GetOffsetAndLength ( utf8 . Length , range ) ;
0 commit comments