#[cfg(test)] mod hex { #[test] fn encode_hex() { let input = vec![0x01, 0x02, 0x03, 0x04, 0x0f, 0xff]; let output = rs_toolbox::serialize::to_hex(input); assert_eq!(output, "010203040fff"); } #[test] fn decode_hex() { let input = "010203040fff"; let output = match rs_toolbox::serialize::from_hex(input) { Ok(v) => v, Err(e) => panic!("Error: {:?}", e), }; assert_eq!(output, vec![0x01, 0x02, 0x03, 0x04, 0x0f, 0xff]); } } #[cfg(test)] mod base64 { #[test] fn encode_base64_str() { let input = "hello"; let output = rs_toolbox::serialize::to_base64_str(input); assert_eq!(output, "aGVsbG8="); } #[test] fn decode_base64_str() { let input = "aGVsbG8="; let output = match rs_toolbox::serialize::from_base64_str(input) { Ok(v) => String::from_utf8(v).unwrap(), Err(e) => panic!("Error: {:?}", e), }; assert_eq!(output, "hello"); } }