@@ -22,6 +22,7 @@ public void BufferAllocationOverLimitTest()
2222 {
2323 { - 1 , 0 , 4 , [ 0xF0 , 0 , 0 , 0 ] } ,
2424 { - 8 , 0 , 4 , [ 0x80 , 0 , 0 , 0 ] } ,
25+ { ( sbyte ) - 1 , 0 , 8 , [ 0xFF , 0 , 0 , 0 ] } ,
2526 { 0xFU , 6 , 4 , [ 0x03 , 0xC0 , 0 , 0 ] } ,
2627 { 0xFU , 1 , 4 , [ 0x78 , 0 , 0 , 0 ] } ,
2728 { 0xFU , 0 , 4 , [ 0xF0 , 0 , 0 , 0 ] } ,
@@ -80,4 +81,46 @@ public void PackedEnumSerializationTest()
8081 offset = BufferUnit . Zero ;
8182 Assert . ThrowsAny < OverflowException > ( ( ) => Serialization . SerializePackedPrimitive ( Status . Fail , buffer , ref offset , size ) ) ;
8283 }
84+
85+ public static TheoryData < object > SignedPrimitiveSerializationTestData
86+ {
87+ get
88+ {
89+ var data = new TheoryData < object >
90+ {
91+ ( object ) ( sbyte ) - 128 ,
92+ ( object ) ( sbyte ) - 1 ,
93+ ( object ) ( sbyte ) 0 ,
94+ ( object ) ( sbyte ) 127 ,
95+ ( object ) short . MinValue ,
96+ ( object ) ( short ) - 1 ,
97+ ( object ) ( short ) 0 ,
98+ ( object ) short . MaxValue ,
99+ ( object ) int . MinValue ,
100+ ( object ) - 1 ,
101+ ( object ) 0 ,
102+ ( object ) int . MaxValue ,
103+ ( object ) long . MinValue ,
104+ ( object ) - 1L ,
105+ ( object ) 0L ,
106+ ( object ) long . MaxValue
107+ } ;
108+ return data ;
109+ }
110+ }
111+
112+ [ MemberData ( nameof ( SignedPrimitiveSerializationTestData ) ) ]
113+ [ Theory ]
114+ public void SignedPrimitiveSerializationTest ( object value )
115+ {
116+ Type valueType = value . GetType ( ) ;
117+ byte [ ] buffer = new byte [ Serialization . GetTypeSize ( valueType ) . Bytes ] ;
118+ BufferUnit offset = BufferUnit . Zero ;
119+
120+ Serialization . SerializePrimitive ( value , buffer , ref offset ) ;
121+
122+ offset = BufferUnit . Zero ;
123+ object actual = Serialization . DeserializePrimitive ( valueType , buffer , ref offset ) ;
124+ Assert . Equal ( value , actual ) ;
125+ }
83126}
0 commit comments