File: oid_tests.rs

package info (click to toggle)
rust-asn1 0.23.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 424 kB
  • sloc: makefile: 2
file content (29 lines) | stat: -rw-r--r-- 855 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#[test]
fn test_oid_value() {
    assert_eq!(
        asn1::oid!(1, 2, 3, 4),
        asn1::ObjectIdentifier::from_string("1.2.3.4").unwrap()
    );
}

#[test]
fn test_oid_with_uuid() {
    const OID_STR: &str = "2.25.223663413560230117710484359924050447509";

    let oid1 = asn1::oid!(2, 25, 223663413560230117710484359924050447509);
    let oid2 = asn1::ObjectIdentifier::from_string(OID_STR).unwrap();

    assert_eq!(oid1, oid2);
    assert_eq!(oid1.to_string(), OID_STR.to_owned());
    assert_eq!(oid2.to_string(), OID_STR.to_owned());
}

#[test]
fn test_match_statement() {
    const OID1: asn1::ObjectIdentifier = asn1::oid!(1, 2, 3, 4);
    const OID2: asn1::ObjectIdentifier = asn1::oid!(1, 2, 3, 5);

    let oid = asn1::ObjectIdentifier::from_string("1.2.3.4").unwrap();
    assert!(matches!(oid, OID1));
    assert!(!matches!(oid, OID2));
}