Move tlv test to tlv.rs

This commit is contained in:
Heiko Schaefer 2021-08-21 17:48:09 +02:00
parent f28c9c2204
commit 0d27352520
2 changed files with 17 additions and 24 deletions

View file

@ -158,27 +158,3 @@ impl KeyType {
}
}
}
#[cfg(test)]
mod test {
use super::tlv::tag::Tag;
use super::tlv::{Tlv, TlvEntry};
#[test]
fn test_tlv() {
let cpkt = Tlv(
Tag(vec![0x7F, 0x48]),
TlvEntry::S(vec![
0x91, 0x03, 0x92, 0x82, 0x01, 0x00, 0x93, 0x82, 0x01, 0x00,
]),
);
assert_eq!(
cpkt.serialize(),
vec![
0x7F, 0x48, 0x0A, 0x91, 0x03, 0x92, 0x82, 0x01, 0x00, 0x93,
0x82, 0x01, 0x00,
]
);
}
}

View file

@ -119,6 +119,23 @@ mod test {
use anyhow::Result;
use hex_literal::hex;
#[test]
fn test_tlv0() {
let cpkt = Tlv(
Tag(vec![0x7F, 0x48]),
TlvEntry::S(vec![
0x91, 0x03, 0x92, 0x82, 0x01, 0x00, 0x93, 0x82, 0x01, 0x00,
]),
);
assert_eq!(
cpkt.serialize(),
vec![
0x7F, 0x48, 0x0A, 0x91, 0x03, 0x92, 0x82, 0x01, 0x00, 0x93,
0x82, 0x01, 0x00,
]
);
}
#[test]
fn test_tlv() -> Result<()> {
// From OpenPGP card spec § 7.2.6