()
| 467 | |
| 468 | #[test] |
| 469 | fn test_codec_4bytes_primitives() { |
| 470 | #[derive(Debug, PartialEq, Eq, PackedSize, EncodeLE, DecodeLE, EncodeBE, DecodeBE)] |
| 471 | struct A { |
| 472 | a: u32, |
| 473 | b: i32, |
| 474 | } |
| 475 | |
| 476 | let test = A { |
| 477 | a: 0x2F, |
| 478 | b: 0x2F000000, |
| 479 | }; |
| 480 | assert_eq!(A::PACKED_LEN, 8); |
| 481 | let mut bytes = [0; A::PACKED_LEN]; |
| 482 | |
| 483 | // LE |
| 484 | let size = test.encode_as_le_bytes(&mut bytes); |
| 485 | assert_eq!([47, 0, 0, 0, 0, 0, 0, 47], bytes); |
| 486 | assert_eq!(A::PACKED_LEN, size); |
| 487 | |
| 488 | let test_back = A::decode_from_le_bytes(&bytes); |
| 489 | assert_eq!(test, test_back); |
| 490 | |
| 491 | //BE |
| 492 | let size = test.encode_as_be_bytes(&mut bytes); |
| 493 | assert_eq!([0, 0, 0, 47, 47, 0, 0, 0], bytes); |
| 494 | assert_eq!(A::PACKED_LEN, size); |
| 495 | |
| 496 | let test_back = A::decode_from_be_bytes(&bytes); |
| 497 | assert_eq!(test, test_back); |
| 498 | } |
| 499 | |
| 500 | #[test] |
| 501 | fn test_codec_8bytes_primitives() { |
nothing calls this directly
no test coverage detected