@@ -223,6 +223,7 @@ ImplDekuTraits!(f64);
223223#[ cfg( test) ]
224224mod tests {
225225 use super :: * ;
226+ use crate :: native_endian;
226227 use rstest:: rstest;
227228
228229 static ENDIAN : Endian = Endian :: new ( ) ;
@@ -244,13 +245,23 @@ mod tests {
244245 }
245246
246247 TestPrimitive ! ( test_u8, u8 , vec![ 0xAAu8 ] , 0xAAu8 ) ;
247- TestPrimitive ! ( test_u16, u16 , vec![ 0xABu8 , 0xCD ] , 0xCDAB ) ;
248- TestPrimitive ! ( test_u32, u32 , vec![ 0xABu8 , 0xCD , 0xEF , 0xBE ] , 0xBEEFCDAB ) ;
248+ TestPrimitive ! (
249+ test_u16,
250+ u16 ,
251+ vec![ 0xABu8 , 0xCD ] ,
252+ native_endian!( 0xCDAB_u16 )
253+ ) ;
254+ TestPrimitive ! (
255+ test_u32,
256+ u32 ,
257+ vec![ 0xABu8 , 0xCD , 0xEF , 0xBE ] ,
258+ native_endian!( 0xBEEFCDAB_u32 )
259+ ) ;
249260 TestPrimitive ! (
250261 test_u64,
251262 u64 ,
252263 vec![ 0xABu8 , 0xCD , 0xEF , 0xBE , 0xAB , 0xCD , 0xFE , 0xC0 ] ,
253- 0xC0FECDABBEEFCDAB
264+ native_endian! ( 0xC0FECDABBEEFCDAB_u64 )
254265 ) ;
255266 TestPrimitive ! (
256267 test_u128,
@@ -259,26 +270,31 @@ mod tests {
259270 0xABu8 , 0xCD , 0xEF , 0xBE , 0xAB , 0xCD , 0xFE , 0xC0 , 0xAB , 0xCD , 0xEF , 0xBE , 0xAB , 0xCD ,
260271 0xFE , 0xC0
261272 ] ,
262- 0xC0FECDABBEEFCDABC0FECDABBEEFCDAB
273+ native_endian! ( 0xC0FECDABBEEFCDABC0FECDABBEEFCDAB_u128 )
263274 ) ;
264275 TestPrimitive ! (
265276 test_usize,
266277 usize ,
267278 vec![ 0xABu8 , 0xCD , 0xEF , 0xBE , 0xAB , 0xCD , 0xFE , 0xC0 ] ,
268279 if core:: mem:: size_of:: <usize >( ) == 8 {
269- 0xC0FECDABBEEFCDAB
280+ native_endian! ( 0xC0FECDABBEEFCDAB_usize )
270281 } else {
271- 0xBEEFCDAB
282+ native_endian! ( 0xBEEFCDAB_usize )
272283 }
273284 ) ;
274285 TestPrimitive ! ( test_i8, i8 , vec![ 0xFBu8 ] , -5 ) ;
275- TestPrimitive ! ( test_i16, i16 , vec![ 0xFDu8 , 0xFE ] , -259 ) ;
276- TestPrimitive ! ( test_i32, i32 , vec![ 0x02u8 , 0x3F , 0x01 , 0xEF ] , -0x10FEC0FE ) ;
286+ TestPrimitive ! ( test_i16, i16 , vec![ 0xFDu8 , 0xFE ] , native_endian!( -259_i16 ) ) ;
287+ TestPrimitive ! (
288+ test_i32,
289+ i32 ,
290+ vec![ 0x02u8 , 0x3F , 0x01 , 0xEF ] ,
291+ native_endian!( -0x10FEC0FE_i32 )
292+ ) ;
277293 TestPrimitive ! (
278294 test_i64,
279295 i64 ,
280296 vec![ 0x02u8 , 0x3F , 0x01 , 0xEF , 0x01 , 0x3F , 0x01 , 0xEF ] ,
281- - 0x10FEC0FE10FEC0FE
297+ native_endian! ( - 0x10FEC0FE10FEC0FE_i64 )
282298 ) ;
283299 TestPrimitive ! (
284300 test_i128,
@@ -287,24 +303,29 @@ mod tests {
287303 0x02u8 , 0x3F , 0x01 , 0xEF , 0x01 , 0x3F , 0x01 , 0xEF , 0x01 , 0x3F , 0x01 , 0xEF , 0x01 , 0x3F ,
288304 0x01 , 0xEF
289305 ] ,
290- - 0x10FEC0FE10FEC0FE10FEC0FE10FEC0FE
306+ native_endian! ( - 0x10FEC0FE10FEC0FE10FEC0FE10FEC0FE_i128 )
291307 ) ;
292308 TestPrimitive ! (
293309 test_isize,
294310 isize ,
295311 vec![ 0x02u8 , 0x3F , 0x01 , 0xEF , 0x01 , 0x3F , 0x01 , 0xEF ] ,
296312 if core:: mem:: size_of:: <isize >( ) == 8 {
297- - 0x10FEC0FE10FEC0FE
313+ native_endian! ( - 0x10FEC0FE10FEC0FE_isize )
298314 } else {
299- - 0x10FEC0FE
315+ native_endian! ( - 0x10FEC0FE_isize )
300316 }
301317 ) ;
302- TestPrimitive ! ( test_f32, f32 , vec![ 0xA6u8 , 0x9B , 0xC4 , 0xBB ] , -0.006 ) ;
318+ TestPrimitive ! (
319+ test_f32,
320+ f32 ,
321+ vec![ 0xA6u8 , 0x9B , 0xC4 , 0xBB ] ,
322+ native_endian!( -0.006_f32 )
323+ ) ;
303324 TestPrimitive ! (
304325 test_f64,
305326 f64 ,
306327 vec![ 0xFAu8 , 0x7E , 0x6A , 0xBC , 0x74 , 0x93 , 0x78 , 0xBF ] ,
307- -0.006
328+ native_endian! ( -0.006_f64 )
308329 ) ;
309330
310331 #[ rstest( input, endian, bit_size, expected, expected_rest,
0 commit comments