-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for #18 (missing constructed bit when serializing [2] IMPLICIT)
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#![cfg(feature = "std")] | ||
|
||
use std::borrow::Cow; | ||
|
||
use asn1_rs::*; | ||
|
||
#[derive(DerSequence, Debug, PartialEq)] | ||
struct Person { | ||
name: String, | ||
age: u16, | ||
} | ||
|
||
#[test] | ||
fn issue_18_1() { | ||
// create a sequence from random data | ||
let seq = Sequence::new(Cow::Borrowed(&[2, 2, 18, 52, 2, 2, 86, 12])); | ||
|
||
// now serialize a [2] IMPLICIT Person | ||
type T2<'a> = TaggedValue<Sequence<'a>, Error, Implicit, { Class::UNIVERSAL }, 2>; | ||
let tagged = T2::implicit(seq); | ||
|
||
let result = tagged.to_der_vec().expect("Could not serialize sequence"); | ||
|
||
let (_, header) = Header::from_der(&result).expect("could not parse serialized data"); | ||
assert!(header.is_constructed()); | ||
} |