ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-BER-XS/t/02_simple.t
(Generate patch)

Comparing Convert-BER-XS/t/02_simple.t (file contents):
Revision 1.15 by root, Thu Apr 25 11:30:21 2019 UTC vs.
Revision 1.16 by root, Thu Apr 25 22:30:21 2019 UTC

1BEGIN { $| = 1; print "1..402\n"; } 1BEGIN { $| = 1; print "1..463\n"; }
2 2
3use common::sense; 3use common::sense;
4use Convert::BER::XS ':all'; 4use Convert::BER::XS ':all';
5 5
6our $test; 6our $test;
91roundtrip "06053305818219", [ASN_UNIVERSAL, ASN_OBJECT_IDENTIFIER, 0, "1.11.5.16665"]; 91roundtrip "06053305818219", [ASN_UNIVERSAL, ASN_OBJECT_IDENTIFIER, 0, "1.11.5.16665"];
92fail "06053305818299", "unexpected end of message buffer"; 92fail "06053305818299", "unexpected end of message buffer";
93roundtrip "0d053305818219", [ASN_UNIVERSAL, ASN_RELATIVE_OID, 0, "51.5.16665"]; 93roundtrip "0d053305818219", [ASN_UNIVERSAL, ASN_RELATIVE_OID, 0, "51.5.16665"];
94fail "0600", "BER_TYPE_OID length"; 94fail "0600", "BER_TYPE_OID length";
95roundtrip "0603818055", [ASN_UNIVERSAL, ASN_OID, 0, "2.16389"]; 95roundtrip "0603818055", [ASN_UNIVERSAL, ASN_OID, 0, "2.16389"];
96fail "06028001", "illegal BER padding"; 96fail "06028001", "invalid BER padding";
97# first component 97# first component
98roundtrip "06022777", [ASN_UNIVERSAL, ASN_OID, 0, "0.39.119"]; 98roundtrip "06022777", [ASN_UNIVERSAL, ASN_OID, 0, "0.39.119"];
99roundtrip "06022877", [ASN_UNIVERSAL, ASN_OID, 0, "1.0.119"]; 99roundtrip "06022877", [ASN_UNIVERSAL, ASN_OID, 0, "1.0.119"];
100roundtrip "06024f77", [ASN_UNIVERSAL, ASN_OID, 0, "1.39.119"]; 100roundtrip "06024f77", [ASN_UNIVERSAL, ASN_OID, 0, "1.39.119"];
101roundtrip "06025077", [ASN_UNIVERSAL, ASN_OID, 0, "2.0.119"]; 101roundtrip "06025077", [ASN_UNIVERSAL, ASN_OID, 0, "2.0.119"];
137fail "308000", "unexpected end"; 137fail "308000", "unexpected end";
138roundtrip "30800000", [ASN_UNIVERSAL, ASN_SEQUENCE, 1], "3000"; 138roundtrip "30800000", [ASN_UNIVERSAL, ASN_SEQUENCE, 1], "3000";
139roundtrip "30800201050000", [ASN_UNIVERSAL, ASN_SEQUENCE, 1], "3003020105"; 139roundtrip "30800201050000", [ASN_UNIVERSAL, ASN_SEQUENCE, 1], "3003020105";
140 140
141# real 141# real
142# 0903acfe05 0.15625 142fail "0901", "unexpected end";
143fail "090240", "unexpected end";
144fail "09024044", "invalid encoding";
145roundtrip "0900", [ASN_UNIVERSAL, ASN_REAL, 0, 0];
146roundtrip "09024040", [ASN_UNIVERSAL, ASN_REAL, 0, undef]; # Inf, string form not portable
147roundtrip "09024041", [ASN_UNIVERSAL, ASN_REAL, 0, undef]; # Inf, string form not portable
148roundtrip "09024042", [ASN_UNIVERSAL, ASN_REAL, 0, undef]; # nan, string form not portable
149roundtrip "09024043", [ASN_UNIVERSAL, ASN_REAL, 0, undef]; # -0 printed as 0 in all tested versions
150
151for (
152 0, -0.1, -1.00001,
153 123456789, -123456789,
154 1.234, -1.234,
155 0.123, -0.123,
156 1/256, -1/256,
157 1e30, 1e-30, -1e30, -1e-30,
158 8e30, -8e30, 5e-30, -5e-30,
159 1.2e20, -1.2e20,
160) {
161 my $ber = ber_encode [ASN_UNIVERSAL, ASN_REAL, 0, $_];
162 my $dec = ber_decode $ber;
163 ok ($_ == $dec->[BER_DATA], "real $_ == $dec->[BER_DATA]");
164}
165
166for (qw(
167 0903acfe05
168 0905adfefe0505
169 0906aefefefe0505
170 0909af0477fefefe050505
171)) {
172 my $ber = ber_decode pack "H*", $_;
173 ok ((ber_is $ber, ASN_UNIVERSAL, ASN_REAL, 0), "$_ $ber->[BER_DATA]");
174}
143 175
144 176

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines