-
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.
Option: require T::Tagged, and check tag before constraints (Closes #27)
- Loading branch information
Showing
2 changed files
with
85 additions
and
2 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
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,71 @@ | ||
use asn1_rs::*; | ||
|
||
#[derive(DerSequence, Debug, PartialEq)] | ||
struct TestBool { | ||
a: u16, | ||
b: Option<bool>, | ||
c: u32, | ||
} | ||
|
||
#[test] | ||
fn issue_27_1() { | ||
let x = TestBool { | ||
a: 0x1234, | ||
b: None, | ||
c: 0x5678, | ||
}; | ||
|
||
let expected = &[48, 8, 2, 2, 18, 52, 2, 2, 86, 120]; | ||
|
||
let (_, val) = TestBool::from_der(expected).unwrap(); | ||
assert_eq!(val, x); | ||
} | ||
|
||
#[test] | ||
fn issue_27_2() { | ||
let x = TestBool { | ||
a: 0x1234, | ||
b: Some(true), | ||
c: 0x5678, | ||
}; | ||
|
||
let expected = &[48, 11, 2, 2, 18, 52, 1, 1, 255, 2, 2, 86, 120]; | ||
|
||
let (_, val) = TestBool::from_der(expected).unwrap(); | ||
assert_eq!(val, x); | ||
} | ||
|
||
#[derive(DerSequence, Debug, PartialEq)] | ||
struct TestInt { | ||
a: u16, | ||
b: Option<u32>, | ||
c: bool, | ||
} | ||
|
||
#[test] | ||
fn issue_27_3() { | ||
let x = TestInt { | ||
a: 0x1234, | ||
b: None, | ||
c: true, | ||
}; | ||
|
||
let expected = &[48, 7, 2, 2, 18, 52, 1, 1, 255]; | ||
|
||
let (_, val) = TestInt::from_der(expected).unwrap(); | ||
assert_eq!(val, x); | ||
} | ||
|
||
#[test] | ||
fn issue_27_4() { | ||
let x = TestInt { | ||
a: 0x1234, | ||
b: Some(0x5678), | ||
c: true, | ||
}; | ||
|
||
let expected = &[48, 11, 2, 2, 18, 52, 2, 2, 86, 120, 1, 1, 255]; | ||
|
||
let (_, val) = TestInt::from_der(expected).unwrap(); | ||
assert_eq!(val, x); | ||
} |