Update of /cvsroot/perl-ldap/asn/t
In directory sc8-pr-cvs1:/tmp/cvs-serv22740/t
Modified Files:
04opt.t funcs.pl
Log Message:
Support OPTIONAL on SET OF and SEQUENCE OF
Index: 04opt.t
===================================================================
RCS file: /cvsroot/perl-ldap/asn/t/04opt.t,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- 04opt.t 25 Mar 2002 14:59:28 -0000 1.3
+++ 04opt.t 7 May 2003 15:13:28 -0000 1.4
@@ -7,7 +7,7 @@
use Convert::ASN1;
BEGIN { require 't/funcs.pl' }
-print "1..12\n"; # This testcase needs more tests
+print "1..16\n"; # This testcase needs more tests
btest 1, $asn = Convert::ASN1->new or warn $asn->error;
btest 2, $asn->prepare(q(
@@ -16,16 +16,34 @@
)) or warn $asn->error;
$result = pack("C*", 0x4, 0x3, ord('a'), ord('b'), ord('c'));
-stest 3, $result, $asn->encode(str => "abc") or warn $asn->error;
+%input = (str => "abc");
+stest 3, $result, $asn->encode(%input) or warn $asn->error;
btest 4, $ret = $asn->decode($result) or warn $asn->error;
-stest 5, "abc", $ret->{str};
-btest 6, !exists $ret->{integer};
+rtest 5, \%input, $ret;
$result = pack("C*", 0x2, 0x1, 0x9, 0x4, 0x3, ord('a'), ord('b'), ord('c'));
-stest 7, $result, $asn->encode(integer => 9, str => "abc") or warn $asn->error;
-btest 8, $ret = $asn->decode($result) or warn $asn->error;
-stest 9, "abc", $ret->{str};
-btest 10, exists $ret->{integer};
-ntest 11, 9, $ret->{integer};
+%input = (integer => 9, str => "abc");
+stest 6, $result, $asn->encode(%input) or warn $asn->error;
+btest 7, $ret = $asn->decode($result) or warn $asn->error;
+rtest 8, \%input, $ret;
-btest 12, not( $asn->encode(integer => 9));
+btest 9, not( $asn->encode(integer => 9));
+
+btest 10, $asn->prepare( q(
+ SEQUENCE {
+ bar [0] SET OF INTEGER OPTIONAL,
+ str OCTET STRING
+ }
+)) or warn $asn->error;
+
+%input = (str => 'Fred');
+$result = pack "H*", "3006040446726564";
+stest 11, $result, $asn->encode(%input);
+btest 12, $ret = $asn->decode($result) or warn $asn->error;
+rtest 13, \%input, $ret;
+
+$result = pack "H*", "3011a009020101020105020103040446726564";
+%input = (str => 'Fred', bar => [1,5,3]);
+stest 14, $result, $asn->encode(%input);
+btest 15, $ret = $asn->decode($result) or warn $asn->error;
+rtest 16, \%input, $ret;
Index: funcs.pl
===================================================================
RCS file: /cvsroot/perl-ldap/asn/t/funcs.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- funcs.pl 26 Apr 2001 06:52:04 -0000 1.4
+++ funcs.pl 7 May 2003 15:13:28 -0000 1.5
@@ -34,5 +34,19 @@
$_[1]
}
+use Data::Dumper;
+
+sub rtest ($$$) {
+ local $Data::Dumper::Sortkeys = 1;
+ my $ok = Dumper($_[1]) eq Dumper($_[2]);
+
+ unless ($ok) {
+ printf "#line %d %s\n",(caller)[2,1];
+ print "not ";
+ }
+ print "ok $_[0]\n";
+ $ok;
+}
+
1;
|