()
| 531 | |
| 532 | #[test] |
| 533 | fn test_codec_16bytes_primitives() { |
| 534 | #[derive(Debug, PartialEq, Eq, PackedSize, EncodeLE, DecodeLE, EncodeBE, DecodeBE)] |
| 535 | struct A { |
| 536 | a: u128, |
| 537 | b: i128, |
| 538 | } |
| 539 | |
| 540 | let test = A { |
| 541 | a: 0x2F, |
| 542 | b: 0x2F000000_00000000_00000000_00000000, |
| 543 | }; |
| 544 | assert_eq!(A::PACKED_LEN, 32); |
| 545 | let mut bytes = [0; A::PACKED_LEN]; |
| 546 | |
| 547 | // LE |
| 548 | let size = test.encode_as_le_bytes(&mut bytes); |
| 549 | assert_eq!( |
| 550 | [ |
| 551 | 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 552 | 0, 0, 0, 0, 47 |
| 553 | ], |
| 554 | bytes |
| 555 | ); |
| 556 | assert_eq!(A::PACKED_LEN, size); |
| 557 | |
| 558 | let test_back = A::decode_from_le_bytes(&bytes); |
| 559 | assert_eq!(test, test_back); |
| 560 | |
| 561 | //BE |
| 562 | let size = test.encode_as_be_bytes(&mut bytes); |
| 563 | assert_eq!( |
| 564 | [ |
| 565 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 566 | 0, 0, 0, 0, 0, |
| 567 | ], |
| 568 | bytes |
| 569 | ); |
| 570 | assert_eq!(A::PACKED_LEN, size); |
| 571 | |
| 572 | let test_back = A::decode_from_be_bytes(&bytes); |
| 573 | assert_eq!(test, test_back); |
| 574 | } |
| 575 | |
| 576 | #[test] |
| 577 | fn test_codec_nested() { |
nothing calls this directly
no test coverage detected