#[cfg(test)]
pub(crate) fn hex_to_bytes(hex: &str) -> Result<Vec<u8>, String> {
if hex.len() % 2 != 0 {
return Err(format!(
"Fix: fixture hex strings must contain an even number of digits, got {}",
hex.len()
));
}
(0..hex.len())
.step_by(2)
.map(|idx| {
u8::from_str_radix(&hex[idx..idx + 2], 16).map_err(|error| {
format!("Fix: fixture hex byte at offset {idx} must be valid hexadecimal: {error}")
})
})
.collect()
}