@@ -105,9 +105,9 @@ public static IEnumerable<ITestData> GetBenchmarkData()
105105 }
106106 }
107107
108- private static IEnumerable < ITestVector > GenerateTestVectors ( IEnumerable < ( Type , object [ ] ) > data , string ? postfix = null , params Type [ ] dataStructs )
108+ private static IEnumerable < ITestVector > GenerateTestVectors ( IEnumerable < ( Type , object [ ] , object [ ] ) > data , string ? postfix = null , params Type [ ] dataStructs )
109109 {
110- foreach ( ( Type vt , object [ ] values ) in data )
110+ foreach ( ( Type vt , object [ ] values , object [ ] notValues ) in data )
111111 {
112112 foreach ( Type st in dataStructs )
113113 {
@@ -118,9 +118,15 @@ private static IEnumerable<ITestVector> GenerateTestVectors(IEnumerable<(Type, o
118118 arr . SetValue ( values [ i ] , i ) ;
119119 }
120120
121+ Array arr2 = Array . CreateInstance ( vt , notValues . Length ) ;
122+ for ( int i = 0 ; i < notValues . Length ; i ++ )
123+ {
124+ arr2 . SetValue ( notValues [ i ] , i ) ;
125+ }
126+
121127 //Create an instance of TestVector<T> and give it the type of the structure
122128 Type vector = typeof ( TestVector < > ) . MakeGenericType ( vt ) ;
123- yield return ( ITestVector ) Activator . CreateInstance ( vector , st , arr , postfix ) ! ;
129+ yield return ( ITestVector ) Activator . CreateInstance ( vector , st , arr , arr2 , postfix ) ! ;
124130 }
125131 }
126132 }
@@ -129,57 +135,57 @@ private static IEnumerable<ITestVector> GenerateTestVectors(IEnumerable<(Type, o
129135 private static IEnumerable < ITestVector > GenerateTestVectors < T > ( IEnumerable < T [ ] > data , params Type [ ] dataStructs )
130136 {
131137 Type type = typeof ( T ) ;
132- return GenerateTestVectors ( data . Select ( x => ( type , x . Cast < object > ( ) . ToArray ( ) ) ) , null , dataStructs ) ;
138+ return GenerateTestVectors ( data . Select ( x => ( type , x . Cast < object > ( ) . ToArray ( ) , Array . Empty < object > ( ) ) ) , null , dataStructs ) ;
133139 }
134140
135- private static IEnumerable < ( Type type , object [ ] value ) > GetEdgeCaseValues ( ) =>
141+ private static IEnumerable < ( Type type , object [ ] value , object [ ] notValue ) > GetEdgeCaseValues ( ) =>
136142 [
137143
138144 // We want to test edge values
139- ( typeof ( sbyte ) , [ sbyte . MinValue , ( sbyte ) - 1 , ( sbyte ) 0 , ( sbyte ) 1 , sbyte . MaxValue ] ) ,
140- ( typeof ( byte ) , [ ( byte ) 0 , ( byte ) 1 , byte . MaxValue ] ) ,
145+ ( typeof ( sbyte ) , [ sbyte . MinValue , ( sbyte ) - 1 , ( sbyte ) 0 , ( sbyte ) 1 , sbyte . MaxValue ] , [ ( sbyte ) - 2 , ( sbyte ) 2 ] ) ,
146+ ( typeof ( byte ) , [ ( byte ) 0 , ( byte ) 1 , byte . MaxValue ] , [ ( byte ) 2 , ( byte ) 3 ] ) ,
141147
142148 //We keep it within ASCII range as C#'s char does not translate to other languages
143- ( typeof ( char ) , [ '\0 ' , 'a' , ( char ) 127 ] ) ,
144- ( typeof ( double ) , [ double . MinValue , 0.0 , 1.0 , double . MaxValue ] ) ,
145- ( typeof ( float ) , [ float . MinValue , - 1f , 0f , 1f , float . MaxValue ] ) ,
146- ( typeof ( short ) , [ short . MinValue , ( short ) - 1 , ( short ) 0 , ( short ) 1 , short . MaxValue ] ) ,
147- ( typeof ( ushort ) , [ ( ushort ) 0 , ( ushort ) 1 , ( ushort ) 2 , ushort . MaxValue ] ) ,
148- ( typeof ( int ) , [ int . MinValue , - 1 , 0 , 1 , int . MaxValue ] ) ,
149- ( typeof ( uint ) , [ 0U , 1U , 2U , uint . MaxValue ] ) ,
150- ( typeof ( long ) , [ long . MinValue , - 1L , 0L , 1L , long . MaxValue ] ) ,
151- ( typeof ( ulong ) , [ 0UL , 1UL , 2UL , ulong . MaxValue ] ) ,
152- ( typeof ( string ) , [ "a" , "item" , new string ( 'a' , 255 ) ] )
149+ ( typeof ( char ) , [ '\0 ' , 'a' , ( char ) 127 ] , [ ( char ) 1 , 'b' ] ) ,
150+ ( typeof ( double ) , [ double . MinValue , 0.0 , 1.0 , double . MaxValue ] , [ 1.1 , 2.0 ] ) ,
151+ ( typeof ( float ) , [ float . MinValue , - 1f , 0f , 1f , float . MaxValue ] , [ 1.1f , 2.0f ] ) ,
152+ ( typeof ( short ) , [ short . MinValue , ( short ) - 1 , ( short ) 0 , ( short ) 1 , short . MaxValue ] , [ ( short ) - 2 , ( short ) 2 ] ) ,
153+ ( typeof ( ushort ) , [ ( ushort ) 0 , ( ushort ) 1 , ( ushort ) 2 , ushort . MaxValue ] , [ ( ushort ) 3 , ( ushort ) 4 ] ) ,
154+ ( typeof ( int ) , [ int . MinValue , - 1 , 0 , 1 , int . MaxValue ] , [ - 2 , 2 ] ) ,
155+ ( typeof ( uint ) , [ 0U , 1U , 2U , uint . MaxValue ] , [ 3U , 4U ] ) ,
156+ ( typeof ( long ) , [ long . MinValue , - 1L , 0L , 1L , long . MaxValue ] , [ - 2L , 2L ] ) ,
157+ ( typeof ( ulong ) , [ 0UL , 1UL , 2UL , ulong . MaxValue ] , [ 3UL , 4UL ] ) ,
158+ ( typeof ( string ) , [ "a" , "item" , new string ( 'a' , 255 ) ] , [ "b" , "item2" ] )
153159 ] ;
154160
155- private static IEnumerable < ( Type type , object [ ] value ) > GetFloatSpecialCases ( ) =>
161+ private static IEnumerable < ( Type type , object [ ] value , object [ ] notValue ) > GetFloatSpecialCases ( ) =>
156162 [
157163
158164 //If we don't have zero or NaN, we can use a simple hash
159- ( typeof ( float ) , [ 1 , 2 , 3 , 4 , 5 ] ) ,
160- ( typeof ( double ) , [ 1 , 2 , 3 , 4 , 5 ] ) ,
165+ ( typeof ( float ) , [ 1 , 2 , 3 , 4 , 5 ] , [ ] ) ,
166+ ( typeof ( double ) , [ 1 , 2 , 3 , 4 , 5 ] , [ ] ) ,
161167 ] ;
162168
163- private static IEnumerable < ( Type type , object [ ] value ) > GetDataOfSize ( int size ) =>
169+ private static IEnumerable < ( Type type , object [ ] value , object [ ] notValue ) > GetDataOfSize ( int size ) =>
164170 [
165- ( typeof ( int ) , Enumerable . Range ( 0 , size ) . Select ( x => x ) . Cast < object > ( ) . ToArray ( ) ) ,
166- ( typeof ( float ) , Enumerable . Range ( 0 , size ) . Select ( x => ( float ) x ) . Cast < object > ( ) . ToArray ( ) ) ,
167- ( typeof ( string ) , Enumerable . Range ( 0 , size ) . Select ( x => x . ToString ( NumberFormatInfo . InvariantInfo ) ) . Cast < object > ( ) . ToArray ( ) )
171+ ( typeof ( int ) , Enumerable . Range ( 0 , size ) . Select ( x => x ) . Cast < object > ( ) . ToArray ( ) , Enumerable . Range ( size , size * 2 ) . Select ( x => x ) . Cast < object > ( ) . ToArray ( ) ) ,
172+ ( typeof ( float ) , Enumerable . Range ( 0 , size ) . Select ( x => ( float ) x ) . Cast < object > ( ) . ToArray ( ) , Enumerable . Range ( size , size * 2 ) . Select ( x => ( float ) x ) . Cast < object > ( ) . ToArray ( ) ) ,
173+ ( typeof ( string ) , Enumerable . Range ( 0 , size ) . Select ( x => x . ToString ( NumberFormatInfo . InvariantInfo ) ) . Cast < object > ( ) . ToArray ( ) , Enumerable . Range ( size , size * 2 ) . Select ( x => x . ToString ( NumberFormatInfo . InvariantInfo ) ) . Cast < object > ( ) . ToArray ( ) )
168174 ] ;
169175
170- private static IEnumerable < ( Type type , object [ ] value ) > GetSingleValues ( ) =>
176+ private static IEnumerable < ( Type type , object [ ] value , object [ ] notValue ) > GetSingleValues ( ) =>
171177 [
172- ( typeof ( sbyte ) , [ ( sbyte ) 1 ] ) ,
173- ( typeof ( byte ) , [ ( byte ) 1 ] ) ,
174- ( typeof ( char ) , [ 'a' ] ) ,
175- ( typeof ( double ) , [ 1.0 ] ) ,
176- ( typeof ( float ) , [ 1f ] ) ,
177- ( typeof ( short ) , [ ( short ) 1 ] ) ,
178- ( typeof ( ushort ) , [ ( ushort ) 1 ] ) ,
179- ( typeof ( int ) , [ 1 ] ) ,
180- ( typeof ( uint ) , [ 1U ] ) ,
181- ( typeof ( long ) , [ 1L ] ) ,
182- ( typeof ( ulong ) , [ 1UL ] ) ,
183- ( typeof ( string ) , [ "value] " ] )
178+ ( typeof ( sbyte ) , [ ( sbyte ) 1 ] , [ ( sbyte ) 2 ] ) ,
179+ ( typeof ( byte ) , [ ( byte ) 1 ] , [ ( byte ) 2 ] ) ,
180+ ( typeof ( char ) , [ 'a' ] , [ 'b' ] ) ,
181+ ( typeof ( double ) , [ 1.0 ] , [ 2.0 ] ) ,
182+ ( typeof ( float ) , [ 1f ] , [ 2f ] ) ,
183+ ( typeof ( short ) , [ ( short ) 1 ] , [ ( short ) 2 ] ) ,
184+ ( typeof ( ushort ) , [ ( ushort ) 1 ] , [ ( ushort ) 2 ] ) ,
185+ ( typeof ( int ) , [ 1 ] , [ 2 ] ) ,
186+ ( typeof ( uint ) , [ 1U ] , [ 2U ] ) ,
187+ ( typeof ( long ) , [ 1L ] , [ 2L ] ) ,
188+ ( typeof ( ulong ) , [ 1UL ] , [ 2UL ] ) ,
189+ ( typeof ( string ) , [ "value" ] , [ "eulav "] )
184190 ] ;
185191}
0 commit comments