diff options
| author | Jack O'Connor <[email protected]> | 2021-02-03 13:27:46 -0500 |
|---|---|---|
| committer | Jack O'Connor <[email protected]> | 2021-02-04 15:36:29 -0500 |
| commit | cc21dd013254624c30fdf461b83a8822d877b9f6 (patch) | |
| tree | 99a9682e0299b2e48244e19b1cbd5cf999142052 /src/test.rs | |
| parent | 9e08f5c38de44b8bb9aeb8a388653458b29e9665 (diff) | |
implement Error for ParseError, make it opaque, and support from_hex(&[u8])
Diffstat (limited to 'src/test.rs')
| -rw-r--r-- | src/test.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/test.rs b/src/test.rs index 6156185..ff9a92d 100644 --- a/src/test.rs +++ b/src/test.rs @@ -586,10 +586,16 @@ fn test_hex_encoding_decoding() { // Test errors let bad_len = "04e0bb39f30b1"; - let result = crate::Hash::from_hex(bad_len).unwrap_err(); - assert_eq!(result, crate::ParseError::InvalidLen); + let _result = crate::Hash::from_hex(bad_len).unwrap_err(); + #[cfg(feature = "std")] + assert_eq!(_result.to_string(), "expected 64 hex bytes, received 13"); let bad_char = "Z4e0bb39f30b1a3feb89f536c93be15055482df748674b00d26e5a75777702e9"; - let result = crate::Hash::from_hex(bad_char).unwrap_err(); - assert_eq!(result, crate::ParseError::InvalidChar); + let _result = crate::Hash::from_hex(bad_char).unwrap_err(); + #[cfg(feature = "std")] + assert_eq!(_result.to_string(), "invalid hex character: 'Z'"); + + let _result = crate::Hash::from_hex([128; 64]).unwrap_err(); + #[cfg(feature = "std")] + assert_eq!(_result.to_string(), "invalid hex character: 0x80"); } |
