()
| 438 | |
| 439 | #[test] |
| 440 | fn test_codec_2bytes_primitives() { |
| 441 | #[derive(Debug, PartialEq, Eq, PackedSize, EncodeLE, DecodeLE, EncodeBE, DecodeBE)] |
| 442 | struct A { |
| 443 | a: u16, |
| 444 | b: i16, |
| 445 | } |
| 446 | |
| 447 | let test = A { a: 0x2F, b: 0x2F00 }; |
| 448 | assert_eq!(A::PACKED_LEN, 4); |
| 449 | let mut bytes = [0; A::PACKED_LEN]; |
| 450 | |
| 451 | // LE |
| 452 | let size = test.encode_as_le_bytes(&mut bytes); |
| 453 | assert_eq!([47, 0, 0, 47], bytes); |
| 454 | assert_eq!(A::PACKED_LEN, size); |
| 455 | |
| 456 | let test_back = A::decode_from_le_bytes(&bytes); |
| 457 | assert_eq!(test, test_back); |
| 458 | |
| 459 | //BE |
| 460 | let size = test.encode_as_be_bytes(&mut bytes); |
| 461 | assert_eq!([0, 47, 47, 0], bytes); |
| 462 | assert_eq!(A::PACKED_LEN, size); |
| 463 | |
| 464 | let test_back = A::decode_from_be_bytes(&bytes); |
| 465 | assert_eq!(test, test_back); |
| 466 | } |
| 467 | |
| 468 | #[test] |
| 469 | fn test_codec_4bytes_primitives() { |
nothing calls this directly
no test coverage detected