@@ -99,7 +99,55 @@ public async Task GetInt64(string column, int[] flags, long[] values)
99
99
await DoGetValue ( column , ( r , n ) => r . GetInt64 ( n ) , ( r , s ) => r . GetInt64 ( s ) , flags , values ) . ConfigureAwait ( false ) ;
100
100
}
101
101
102
- private async Task DoGetValue < T > ( string column , Func < DbDataReader , int , T > getInt , Func < MySqlDataReader , string , T > getIntByName , int [ ] flags , T [ ] values )
102
+ [ Theory ]
103
+ [ InlineData ( "SByte" , new [ ] { 1 , 0 , 2 , 0 , 0 } , new ushort [ ] { 0 , 0 , 0 , 127 , 123 } ) ]
104
+ [ InlineData ( "Byte" , new [ ] { 1 , 0 , 0 , 0 , 0 } , new ushort [ ] { 0 , 0 , 0 , 255 , 123 } ) ]
105
+ [ InlineData ( "Int16" , new [ ] { 1 , 0 , 2 , 0 , 0 } , new ushort [ ] { 0 , 0 , 0 , 32767 , 12345 } ) ]
106
+ [ InlineData ( "UInt16" , new [ ] { 1 , 0 , 0 , 0 , 0 } , new ushort [ ] { 0 , 0 , 0 , 65535 , 12345 } ) ]
107
+ [ InlineData ( "Int24" , new [ ] { 1 , 0 , 2 , 2 , 2 } , new ushort [ ] { 0 , 0 , 0 , 0 , 0 } ) ]
108
+ [ InlineData ( "UInt24" , new [ ] { 1 , 0 , 0 , 2 , 2 } , new ushort [ ] { 0 , 0 , 0 , 0 , 0 } ) ]
109
+ [ InlineData ( "Int32" , new [ ] { 1 , 0 , 2 , 2 , 2 } , new ushort [ ] { 0 , 0 , 0 , 0 , 0 } ) ]
110
+ [ InlineData ( "UInt32" , new [ ] { 1 , 0 , 0 , 2 , 2 } , new ushort [ ] { 0 , 0 , 0 , 0 , 0 } ) ]
111
+ [ InlineData ( "Int64" , new [ ] { 1 , 0 , 2 , 2 , 2 } , new ushort [ ] { 0 , 0 , 0 , 0 , 0 } ) ]
112
+ [ InlineData ( "UInt64" , new [ ] { 1 , 0 , 0 , 2 , 2 } , new ushort [ ] { 0 , 0 , 0 , 0 , 0 } ) ]
113
+ public async Task GetUInt16 ( string column , int [ ] flags , ushort [ ] values )
114
+ {
115
+ await DoGetValue ( column , ( r , n ) => r . GetUInt16 ( n ) , ( r , s ) => r . GetUInt16 ( s ) , flags , values ) . ConfigureAwait ( false ) ;
116
+ }
117
+
118
+ [ Theory ]
119
+ [ InlineData ( "SByte" , new [ ] { 1 , 0 , 2 , 0 , 0 } , new uint [ ] { 0 , 0 , 0 , 127 , 123 } ) ]
120
+ [ InlineData ( "Byte" , new [ ] { 1 , 0 , 0 , 0 , 0 } , new uint [ ] { 0 , 0 , 0 , 255 , 123 } ) ]
121
+ [ InlineData ( "Int16" , new [ ] { 1 , 0 , 2 , 0 , 0 } , new uint [ ] { 0 , 0 , 0 , 32767 , 12345 } ) ]
122
+ [ InlineData ( "UInt16" , new [ ] { 1 , 0 , 0 , 0 , 0 } , new uint [ ] { 0 , 0 , 0 , 65535 , 12345 } ) ]
123
+ [ InlineData ( "Int24" , new [ ] { 1 , 0 , 2 , 0 , 0 } , new uint [ ] { 0 , 0 , 0 , 8388607 , 1234567 } ) ]
124
+ [ InlineData ( "UInt24" , new [ ] { 1 , 0 , 0 , 0 , 0 } , new uint [ ] { 0 , 0 , 0 , 16777215 , 1234567 } ) ]
125
+ [ InlineData ( "Int32" , new [ ] { 1 , 0 , 2 , 0 , 0 } , new uint [ ] { 0 , 0 , 0 , 2147483647 , 123456789 } ) ]
126
+ [ InlineData ( "UInt32" , new [ ] { 1 , 0 , 0 , 0 , 0 } , new uint [ ] { 0 , 0 , 0 , 4294967295 , 123456789 } ) ]
127
+ [ InlineData ( "Int64" , new [ ] { 1 , 0 , 2 , 2 , 2 } , new uint [ ] { 0 , 0 , 0 , 0 , 0 } ) ]
128
+ [ InlineData ( "UInt64" , new [ ] { 1 , 0 , 0 , 2 , 2 } , new uint [ ] { 0 , 0 , 0 , 0 , 0 } ) ]
129
+ public async Task GetUInt32 ( string column , int [ ] flags , uint [ ] values )
130
+ {
131
+ await DoGetValue ( column , ( r , n ) => r . GetUInt32 ( n ) , ( r , s ) => r . GetUInt32 ( s ) , flags , values ) . ConfigureAwait ( false ) ;
132
+ }
133
+
134
+ [ Theory ]
135
+ [ InlineData ( "SByte" , new [ ] { 1 , 0 , 2 , 0 , 0 } , new ulong [ ] { 0 , 0 , 0 , 127 , 123 } ) ]
136
+ [ InlineData ( "Byte" , new [ ] { 1 , 0 , 0 , 0 , 0 } , new ulong [ ] { 0 , 0 , 0 , 255 , 123 } ) ]
137
+ [ InlineData ( "Int16" , new [ ] { 1 , 0 , 2 , 0 , 0 } , new ulong [ ] { 0 , 0 , 0 , 32767 , 12345 } ) ]
138
+ [ InlineData ( "UInt16" , new [ ] { 1 , 0 , 0 , 0 , 0 } , new ulong [ ] { 0 , 0 , 0 , 65535 , 12345 } ) ]
139
+ [ InlineData ( "Int24" , new [ ] { 1 , 0 , 2 , 0 , 0 } , new ulong [ ] { 0 , 0 , 0 , 8388607 , 1234567 } ) ]
140
+ [ InlineData ( "UInt24" , new [ ] { 1 , 0 , 0 , 0 , 0 } , new ulong [ ] { 0 , 0 , 0 , 16777215 , 1234567 } ) ]
141
+ [ InlineData ( "Int32" , new [ ] { 1 , 0 , 2 , 0 , 0 } , new ulong [ ] { 0 , 0 , 0 , 2147483647 , 123456789 } ) ]
142
+ [ InlineData ( "UInt32" , new [ ] { 1 , 0 , 0 , 0 , 0 } , new ulong [ ] { 0 , 0 , 0 , 4294967295 , 123456789 } ) ]
143
+ [ InlineData ( "Int64" , new [ ] { 1 , 0 , 2 , 0 , 0 } , new ulong [ ] { 0 , 0 , 0 , 9223372036854775807 , 1234567890123456789 } ) ]
144
+ [ InlineData ( "UInt64" , new [ ] { 1 , 0 , 0 , 0 , 0 } , new ulong [ ] { 0 , 0 , 0 , 18446744073709551615 , 1234567890123456789 } ) ]
145
+ public async Task GetUInt64 ( string column , int [ ] flags , ulong [ ] values )
146
+ {
147
+ await DoGetValue ( column , ( r , n ) => r . GetUInt64 ( n ) , ( r , s ) => r . GetUInt64 ( s ) , flags , values ) . ConfigureAwait ( false ) ;
148
+ }
149
+
150
+ private async Task DoGetValue < T > ( string column , Func < MySqlDataReader , int , T > getInt , Func < MySqlDataReader , string , T > getIntByName , int [ ] flags , T [ ] values )
103
151
{
104
152
using ( var cmd = m_database . Connection . CreateCommand ( ) )
105
153
{
@@ -202,7 +250,7 @@ public void QueryInt16(string column, string dataTypeName, object[] expected)
202
250
[ InlineData ( "UInt16" , "SMALLINT" , new object [ ] { null , default ( ushort ) , ushort . MinValue , ushort . MaxValue , ( ushort ) 12345 } ) ]
203
251
public void QueryUInt16 ( string column , string dataTypeName , object [ ] expected )
204
252
{
205
- DoQuery < InvalidCastException > ( "integers" , column , dataTypeName , expected , reader => reader . GetFieldValue < ushort > ( 0 ) ) ;
253
+ DoQuery ( "integers" , column , dataTypeName , expected , reader => reader . GetUInt16 ( column ) ) ;
206
254
}
207
255
208
256
[ Theory ]
@@ -222,7 +270,7 @@ public void QueryUInt32(string column, string dataTypeName, object[] expected)
222
270
// mysql-connector-net incorrectly returns "INT" for "MEDIUMINT UNSIGNED"
223
271
dataTypeName = "INT" ;
224
272
#endif
225
- DoQuery < InvalidCastException > ( "integers" , column , dataTypeName , expected , reader => reader . GetFieldValue < uint > ( 0 ) ) ;
273
+ DoQuery ( "integers" , column , dataTypeName , expected , reader => reader . GetUInt32 ( column ) ) ;
226
274
}
227
275
228
276
[ Theory ]
@@ -236,7 +284,7 @@ public void QueryInt64(string column, string dataTypeName, object[] expected)
236
284
[ InlineData ( "UInt64" , "BIGINT" , new object [ ] { null , default ( ulong ) , ulong . MinValue , ulong . MaxValue , 1234567890123456789u } ) ]
237
285
public void QueryUInt64 ( string column , string dataTypeName , object [ ] expected )
238
286
{
239
- DoQuery < InvalidCastException > ( "integers" , column , dataTypeName , expected , reader => reader . GetFieldValue < ulong > ( 0 ) ) ;
287
+ DoQuery ( "integers" , column , dataTypeName , expected , reader => reader . GetUInt64 ( 0 ) ) ;
240
288
}
241
289
242
290
[ Theory ]
@@ -245,7 +293,7 @@ public void QueryUInt64(string column, string dataTypeName, object[] expected)
245
293
[ InlineData ( "Bit64" , new object [ ] { null , 0UL , 1UL , ulong . MaxValue } ) ]
246
294
public void QueryBits ( string column , object [ ] expected )
247
295
{
248
- DoQuery < InvalidCastException > ( "bits" , column , "BIT" , expected , reader => reader . GetFieldValue < ulong > ( 0 ) ) ;
296
+ DoQuery ( "bits" , column , "BIT" , expected , reader => reader . GetUInt64 ( column ) ) ;
249
297
}
250
298
251
299
[ Theory ]
0 commit comments