File: 11explicit.t

package info (click to toggle)
libconvert-asn1-perl 0.34-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 468 kB
  • sloc: perl: 4,526; yacc: 544; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 552 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
30
31
32
#!/usr/local/bin/perl

BEGIN { require './t/funcs.pl' }

use Convert::ASN1;

print "1..4\n";

my $asn;

btest 1, $asn = Convert::ASN1->new or warn $asn->error;
btest 2, $asn->prepare(q(
  Message ::=  CHOICE
  {
    a A,
    b B
  }

  A ::= [2] EXPLICIT INTEGER
  B ::= [3] EXPLICIT INTEGER

 )) || die $asn->error;

my $mm = $asn->find("Message") || die $asn->error;

my $buffer = pack("H*","a203020105");

my $input = { a => 5 };

my $result = $mm->encode($input) || die $mm->error;
stest 3, $buffer, $result;
rtest 4, $input, $mm->decode($buffer);