Skip to content

Commit

Permalink
wip: review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
cpu committed Nov 28, 2023
1 parent 37148da commit 3c7f545
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,23 +523,28 @@ impl DerInner<'_> {

// Format an iterator of u8 into a hex string
fn hex<'a>(f: &mut fmt::Formatter<'_>, payload: impl IntoIterator<Item = &'a u8>) -> fmt::Result {
for b in payload {
for (i, b) in payload.into_iter().enumerate() {
if i == 0 {
write!(f, "0x")?;
}
write!(f, "{:02x}", b)?;
}
Ok(())
}

#[cfg(feature = "std")]
mod tests {
use super::*;

#[test]
fn der_debug() {
let der = super::Der::from_slice(&[0x01, 0x02, 0x03]);
assert_eq!(format!("{:?}", der), "010203");
let der = Der::from_slice(&[0x01, 0x02, 0x03]);
assert_eq!(format!("{:?}", der), "0x010203");
}

#[test]
fn algid_debug() {
let algid = super::AlgorithmIdentifier::from_slice(&[0x01, 0x02, 0x03]);
assert_eq!(format!("{:?}", algid), "010203");
fn alg_id_debug() {
let alg_id = AlgorithmIdentifier::from_slice(&[0x01, 0x02, 0x03]);
assert_eq!(format!("{:?}", alg_id), "0x010203");
}
}

0 comments on commit 3c7f545

Please sign in to comment.