Skip to content

Commit ad41d37

Browse files
author
Harris Kaufmann
committed
unit tests to be fixed?
1 parent a46e366 commit ad41d37

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

der/src/tag.rs

+22-1
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,10 @@ impl fmt::Debug for Tag {
495495

496496
#[cfg(test)]
497497
mod tests {
498+
use hex_literal::hex;
499+
498500
use super::{Class, Tag, TagNumber};
499-
use crate::{Length, Reader, SliceReader};
501+
use crate::{Decode, ErrorKind, Length, Reader, SliceReader};
500502

501503
#[test]
502504
fn tag_class() {
@@ -561,4 +563,23 @@ mod tests {
561563
assert_eq!(Tag::peek(&reader).unwrap(), Tag::Integer);
562564
assert_eq!(reader.position(), Length::ZERO); // Position unchanged
563565
}
566+
567+
#[test]
568+
fn decoding() {
569+
// valid tag number but must be in short form
570+
assert_eq!(
571+
ErrorKind::TagNumberInvalid,
572+
Tag::from_der(&hex!("FF03")).unwrap_err().kind()
573+
);
574+
// universal tag with long form
575+
assert_eq!(
576+
ErrorKind::TagNumberInvalid,
577+
Tag::from_der(&hex!("1FFF")).unwrap_err().kind()
578+
);
579+
// leading zeros in long form
580+
assert_eq!(
581+
ErrorKind::TagNumberInvalid,
582+
Tag::from_der(&hex!("5F8020")).unwrap_err().kind()
583+
);
584+
}
564585
}

0 commit comments

Comments
 (0)