@@ -16,7 +16,7 @@ public static class DecoderTest
1616 [ MemberData ( nameof ( TestUInt16 ) ) ]
1717 [ MemberData ( nameof ( TestUInt32 ) ) ]
1818 [ MemberData ( nameof ( TestInt32s ) ) ]
19- [ MemberData ( nameof ( TestInt64s ) ) ]
19+ [ MemberData ( nameof ( TestUInt64s ) ) ]
2020 [ MemberData ( nameof ( TestBigIntegers ) ) ]
2121 [ MemberData ( nameof ( TestDoubles ) ) ]
2222 [ MemberData ( nameof ( TestFloats ) ) ]
@@ -26,7 +26,7 @@ public static class DecoderTest
2626 [ MemberData ( nameof ( TestBytes ) ) ]
2727 [ MemberData ( nameof ( TestMaps ) ) ]
2828 [ MemberData ( nameof ( TestArrays ) ) ]
29- public static void TestTypeDecoding < T > ( Dictionary < T , byte [ ] > tests , bool useShouldBe = false ) where T : class
29+ public static void TestTypeDecoding < T > ( Dictionary < T , byte [ ] > tests ) where T : class
3030 {
3131 foreach ( var entry in tests )
3232 {
@@ -36,14 +36,7 @@ public static void TestTypeDecoding<T>(Dictionary<T, byte[]> tests, bool useShou
3636 using var database = new ArrayBuffer ( input ) ;
3737 var decoder = new Decoder ( database , 0 , false ) ;
3838 var val = decoder . Decode < T > ( 0 , out _ ) ;
39- if ( useShouldBe )
40- {
4139 Assert . Equal ( expect , val ) ;
42- }
43- else
44- {
45- Assert . Equivalent ( expect , val ) ;
46- }
4740 }
4841 }
4942
@@ -55,7 +48,7 @@ public static IEnumerable<object[]> TestUInt16()
5548 { ( 1 << 8 ) - 1 , [ 0xa1 , 0xff ] } ,
5649 { 500 , [ 0xa2 , 0x1 , 0xf4 ] } ,
5750 { 10872 , [ 0xa2 , 0x2a , 0x78 ] } ,
58- { ushort . MaxValue , [ 0xa2 , 0xff , 0xff ] }
51+ { ( int ) ushort . MaxValue , [ 0xa2 , 0xff , 0xff ] }
5952 } ;
6053
6154 yield return [ uint16s ] ;
@@ -65,13 +58,13 @@ public static IEnumerable<object[]> TestUInt32()
6558 {
6659 var uint32s = new Dictionary < object , byte [ ] >
6760 {
68- { 0 , [ 0xc0 ] } ,
69- { ( 1 << 8 ) - 1 , [ 0xc1 , 0xff ] } ,
70- { 500 , [ 0xc2 , 0x1 , 0xf4 ] } ,
71- { 10872 , [ 0xc2 , 0x2a , 0x78 ] } ,
72- { ( 1 << 16 ) - 1 , [ 0xc2 , 0xff , 0xff ] } ,
73- { ( 1 << 24 ) - 1 , [ 0xc3 , 0xff , 0xff , 0xff ] } ,
74- { uint . MaxValue , [ 0xc4 , 0xff , 0xff , 0xff , 0xff ] }
61+ { 0L , [ 0xc0 ] } ,
62+ { ( 1L << 8 ) - 1 , [ 0xc1 , 0xff ] } ,
63+ { 500L , [ 0xc2 , 0x1 , 0xf4 ] } ,
64+ { 10872L , [ 0xc2 , 0x2a , 0x78 ] } ,
65+ { ( 1L << 16 ) - 1 , [ 0xc2 , 0xff , 0xff ] } ,
66+ { ( 1L << 24 ) - 1 , [ 0xc3 , 0xff , 0xff , 0xff ] } ,
67+ { ( long ) uint . MaxValue , [ 0xc4 , 0xff , 0xff , 0xff , 0xff ] }
7568 } ;
7669
7770 yield return [ uint32s ] ;
@@ -98,18 +91,18 @@ public static IEnumerable<object[]> TestInt32s()
9891 yield return [ int32s ] ;
9992 }
10093
101- public static IEnumerable < object [ ] > TestInt64s ( )
94+ public static IEnumerable < object [ ] > TestUInt64s ( )
10295 {
103- var int64s = new Dictionary < object , byte [ ] >
96+ var uint64s = new Dictionary < object , byte [ ] >
10497 {
105- { 0L , [ 0x0 , 0x2 ] } ,
106- { 500L , [ 0x2 , 0x2 , 0x1 , 0xf4 ] } ,
107- { 10872 , [ 0x2 , 0x2 , 0x2a , 0x78 ] }
98+ { 0UL , [ 0x0 , 0x2 ] } ,
99+ { 500UL , [ 0x2 , 0x2 , 0x1 , 0xf4 ] } ,
100+ { 10872UL , [ 0x2 , 0x2 , 0x2a , 0x78 ] }
108101 } ;
109102
110103 for ( var power = 1 ; power < 8 ; power ++ )
111104 {
112- var key = Int64Pow ( 2 , 8 * power ) - 1 ;
105+ var key = UInt64Pow ( 2 , 8 * power ) - 1 ;
113106 var value = new byte [ 2 + power ] ;
114107
115108 value [ 0 ] = ( byte ) power ;
@@ -119,15 +112,15 @@ public static IEnumerable<object[]> TestInt64s()
119112 value [ i ] = 0xff ;
120113 }
121114
122- int64s . Add ( key , value ) ;
115+ uint64s . Add ( key , value ) ;
123116 }
124117
125- yield return [ int64s ] ;
118+ yield return [ uint64s ] ;
126119 }
127120
128- public static long Int64Pow ( long x , int pow )
121+ public static ulong UInt64Pow ( ulong x , int pow )
129122 {
130- long ret = 1 ;
123+ ulong ret = 1 ;
131124 while ( pow != 0 )
132125 {
133126 if ( ( pow & 1 ) == 1 )
@@ -162,7 +155,7 @@ public static IEnumerable<object[]> TestBigIntegers()
162155 bigInts . Add ( key , value ) ;
163156 }
164157
165- yield return [ bigInts , /*useShouldBe*/ true ] ;
158+ yield return [ bigInts ] ;
166159 }
167160
168161 public static IEnumerable < object [ ] > TestDoubles ( )
@@ -204,16 +197,16 @@ public static IEnumerable<object[]> TestPointers()
204197 {
205198 var pointers = new Dictionary < object , byte [ ] >
206199 {
207- { 0 , [ 0x20 , 0x0 ] } ,
208- { 5 , [ 0x20 , 0x5 ] } ,
209- { 10 , [ 0x20 , 0xa ] } ,
210- { ( 1 << 10 ) - 1 , [ 0x23 , 0xff ] } ,
211- { 3017 , [ 0x28 , 0x3 , 0xc9 ] } ,
212- { ( 1 << 19 ) - 5 , [ 0x2f , 0xf7 , 0xfb ] } ,
213- { ( 1 << 19 ) + ( 1 << 11 ) - 1 , [ 0x2f , 0xff , 0xff ] } ,
214- { ( 1 << 27 ) - 2 , [ 0x37 , 0xf7 , 0xf7 , 0xfe ] } ,
215- { ( ( long ) 1 << 27 ) + ( 1 << 19 ) + ( 1 << 11 ) - 1 , [ 0x37 , 0xff , 0xff , 0xff ] } ,
216- { ( ( long ) 1 << 31 ) - 1 , [ 0x38 , 0x7f , 0xff , 0xff , 0xff ] }
200+ { 0L , [ 0x20 , 0x0 ] } ,
201+ { 5L , [ 0x20 , 0x5 ] } ,
202+ { 10L , [ 0x20 , 0xa ] } ,
203+ { ( 1L << 10 ) - 1 , [ 0x23 , 0xff ] } ,
204+ { 3017L , [ 0x28 , 0x3 , 0xc9 ] } ,
205+ { ( 1L << 19 ) - 5 , [ 0x2f , 0xf7 , 0xfb ] } ,
206+ { ( 1L << 19 ) + ( 1 << 11 ) - 1 , [ 0x2f , 0xff , 0xff ] } ,
207+ { ( 1L << 27 ) - 2 , [ 0x37 , 0xf7 , 0xf7 , 0xfe ] } ,
208+ { ( 1L << 27 ) + ( 1 << 19 ) + ( 1 << 11 ) - 1 , [ 0x37 , 0xff , 0xff , 0xff ] } ,
209+ { ( 1L << 31 ) - 1 , [ 0x38 , 0x7f , 0xff , 0xff , 0xff ] }
217210 } ;
218211
219212 yield return [ pointers ] ;
0 commit comments