#[cfg(test)] mod test { use byte_operations::Bytes; use byte_operations::Bytes::{Byte, Word}; #[test] fn test_byte_into_2_nibbles() { let (a, b) = Byte(0xab).into(); assert_eq!((a, b), (0xa, 0xb)); } #[test] fn test_word_into_2_bytes() { let (a, b) = Word(0xabfd).into(); assert_eq!((a, b), (0xab, 0xfd)); } #[test] #[should_panic] fn test_byte_into_4_nibbles() { let (_, _, _, _) = Byte(0xcd).into(); } #[test] fn test_word_into_4_nibbles() { let (a, b, c, d) = Word(0xafb1).into(); assert_eq!((a, b, c, d), (0xa, 0xf, 0xb, 0x1)); } #[test] fn test_word_from_bytes() { if let Word(word) = Bytes::from((0xf3, 0x2b)) { assert_eq!(word, 0xf32b); } } }