mirror of https://github.com/briansmith/webpki
Add test coverage for der.rs
This commit is contained in:
parent
db24fe8153
commit
3c1abded71
35
src/der.rs
35
src/der.rs
|
@ -211,5 +211,38 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_bit_string_with_no_unused_bits() {}
|
||||
fn test_bit_string_with_no_unused_bits() {
|
||||
use super::{bit_string_with_no_unused_bits, Error};
|
||||
|
||||
// Unexpected type
|
||||
assert_eq!(
|
||||
Err(Error::BadDer),
|
||||
bit_string_with_no_unused_bits(&mut bytes_reader(&[0x01, 0x01, 0xff]))
|
||||
);
|
||||
|
||||
// Unexpected nonexistent type
|
||||
assert_eq!(
|
||||
Err(Error::BadDer),
|
||||
bit_string_with_no_unused_bits(&mut bytes_reader(&[0x42, 0xff, 0xff]))
|
||||
);
|
||||
|
||||
// Unexpected empty input
|
||||
assert_eq!(
|
||||
Err(Error::BadDer),
|
||||
bit_string_with_no_unused_bits(&mut bytes_reader(&[]))
|
||||
);
|
||||
|
||||
// Valid input with non-zero unused bits
|
||||
assert_eq!(
|
||||
Err(Error::BadDer),
|
||||
bit_string_with_no_unused_bits(&mut bytes_reader(&[0x03, 0x03, 0x04, 0x12, 0x34]))
|
||||
);
|
||||
|
||||
// Valid input
|
||||
assert_eq!(
|
||||
untrusted::Input::from(&[0x12, 0x34]),
|
||||
bit_string_with_no_unused_bits(&mut bytes_reader(&[0x03, 0x03, 0x00, 0x12, 0x34])).unwrap()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue