File: issue-43-encoding-large-tags.rs

package info (click to toggle)
rust-asn1-rs 0.7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 996 kB
  • sloc: makefile: 13; sh: 1
file content (16 lines) | stat: -rw-r--r-- 496 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#![cfg(feature = "std")]

use asn1_rs::{Any, FromDer, Integer, Tag, ToDer};

#[test]
fn encode_large_tag() {
    const EXPECTED_TAG: u32 = 0x41424344;
    let data = Integer::from(1).to_der_vec().unwrap();
    let any = &Any::from_tag_and_data(Tag::from(EXPECTED_TAG), &data);
    let tmp = any.to_der_vec().unwrap();

    let expect = Tag::from(EXPECTED_TAG);
    let actual = Any::from_der(&tmp).unwrap().1.tag();

    assert_eq!(expect, actual, "expected tag {expect}, found tag {actual}");
}