From 0d27352520e1f125b86a143db43964be7106cd31 Mon Sep 17 00:00:00 2001 From: Heiko Schaefer Date: Sat, 21 Aug 2021 17:48:09 +0200 Subject: [PATCH] Move tlv test to tlv.rs --- openpgp-card/src/lib.rs | 24 ------------------------ openpgp-card/src/tlv/mod.rs | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/openpgp-card/src/lib.rs b/openpgp-card/src/lib.rs index 022c9fd..4995cd5 100644 --- a/openpgp-card/src/lib.rs +++ b/openpgp-card/src/lib.rs @@ -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, - ] - ); - } -} diff --git a/openpgp-card/src/tlv/mod.rs b/openpgp-card/src/tlv/mod.rs index 0bd40a4..5d74e9f 100644 --- a/openpgp-card/src/tlv/mod.rs +++ b/openpgp-card/src/tlv/mod.rs @@ -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