diff options
Diffstat (limited to 'rust/vendor/der-parser-6.0.1/tests/oid.rs')
-rw-r--r-- | rust/vendor/der-parser-6.0.1/tests/oid.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/rust/vendor/der-parser-6.0.1/tests/oid.rs b/rust/vendor/der-parser-6.0.1/tests/oid.rs new file mode 100644 index 0000000..5cffad4 --- /dev/null +++ b/rust/vendor/der-parser-6.0.1/tests/oid.rs @@ -0,0 +1,25 @@ +//! Test the API provided to compare OIDs + +extern crate alloc; +use der_parser::oid; +use der_parser::oid::Oid; + +const OID_RSA_ENCRYPTION: &[u8] = &oid!(raw 1.2.840.113549.1.1.1); +const OID_EC_PUBLIC_KEY: &[u8] = &oid!(raw 1.2.840.10045.2.1); +#[allow(clippy::match_like_matches_macro)] +fn compare_oid(oid: &Oid) -> bool { + match oid.bytes() { + OID_RSA_ENCRYPTION => true, + OID_EC_PUBLIC_KEY => true, + _ => false, + } +} + +#[rustfmt::skip::macros(oid)] +#[test] +fn test_compare_oid() { + let oid = Oid::from(&[1, 2, 840, 113_549, 1, 1, 1]).unwrap(); + assert_eq!(oid, oid!(1.2.840.113549.1.1.1)); + let oid = Oid::from(&[1, 2, 840, 113_549, 1, 1, 1]).unwrap(); + assert!(compare_oid(&oid)); +} |