Skip to content

Commit

Permalink
Fix trace message to indicate the generic type
Browse files Browse the repository at this point in the history
  • Loading branch information
chifflier committed Apr 9, 2024
1 parent 9690362 commit a69ec1a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,18 @@ mod tests {
assert!(Any::from_der(&hex!("01 01 ff")).is_ok());
}

#[test]
fn debug_from_der_bool() {
eprintln!("** first test is ok**");
assert!(<bool>::from_der(&hex!("01 01 ff")).is_ok());
eprintln!("** second test fails when parsing ANY (eof)**");
assert!(<bool>::from_der(&hex!("01 02 ff")).is_err());
eprintln!("** second test fails when checking DER constraints**");
assert!(<bool>::from_der(&hex!("01 01 f0")).is_err());
eprintln!("** second test fails during TryFrom**");
assert!(<bool>::from_der(&hex!("01 02 ff ff")).is_err());
}

#[test]
fn debug_from_der_failures() {
use crate::Sequence;
Expand Down
2 changes: 1 addition & 1 deletion src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ where
fn from_der(bytes: &'a [u8]) -> ParseResult<T, E> {
trace_generic(
core::any::type_name::<T>(),
"Any::from_der",
"T::from_der",
|bytes| {
let (i, any) = trace(core::any::type_name::<T>(), parse_der_any, bytes)
.map_err(nom::Err::convert)?;
Expand Down

0 comments on commit a69ec1a

Please sign in to comment.