pub fn test_codec<D: Codec + PartialEq + Debug>(
encoded_bytes: &[u8],
v: &D,
) -> Result<(), Error>Expand description
Comprehensively tests a codec implementation with both valid and corrupted data.
This function performs several checks:
- Encodes the value and verifies it matches the expected bytes
- Decodes the encoded bytes and verifies it matches the original value
- Tests error handling by corrupting each byte and ensuring decode fails
§Arguments
encoded_bytes- The expected encoded representationv- The value to test encoding/decoding
§Returns
Ok(()) if all tests pass, io::Error if any encoding/decoding operation fails