ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CBOR-XS/t/53_bignum.t
Revision: 1.3
Committed: Fri Nov 22 15:44:13 2013 UTC (10 years, 6 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-1_11, rel-1_12, rel-1_1, rel-1_0, rel-1_3, rel-1_4, rel-0_09, rel-1_25, rel-1_26, rel-1_41
Changes since 1.2: +1 -1 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.2 BEGIN { $| = 1; print "1..100\n"; }
2 root 1.1 BEGIN { $^W = 0 } # hate
3    
4     use CBOR::XS;
5    
6     print "ok 1\n";
7    
8     my $t = decode_cbor pack "H*", "82c48221196ab3c5822003";
9    
10     print $t->[0] eq "273.15" ? "" : "not ", "ok 2 # $t->[0]\n";
11     print $t->[1] eq "1.5" ? "" : "not ", "ok 3 # $t->[1]\n";
12    
13     $t = encode_cbor $t;
14    
15     print $t eq (pack "H*", "82c48221196ab3c482200f") ? "" : "not ", "ok 4 # ", (unpack "H*", $t), "\n";
16    
17 root 1.3 # Math::BigFloat is loaded by now...
18 root 1.2
19     for (5..99) {
20     my $n = Math::BigFloat->new ((int rand 1e9) . "." . (int rand 1e9) . "e" . ((int rand 1e8) - 0.5e8));
21     my $m = decode_cbor encode_cbor $n;
22    
23     $n = $n->bsstr;
24     $m = $m->bsstr;
25    
26     print $n != $m ? "not " : "ok $_ # $n eq $m\n";
27     }
28    
29     print "ok 100\n";
30