File: mbi_ltm_bigintpm.t

package info (click to toggle)
libcryptx-perl 0.087-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,212 kB
  • sloc: ansic: 59,240; perl: 3,828; pascal: 2,612; makefile: 201
file content (52 lines) | stat: -rw-r--r-- 1,457 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!perl

use strict;
use warnings;

use Test::More;

BEGIN {
  plan skip_all => "requires Math::BigInt 1.999827+" unless eval { require Math::BigInt && eval($Math::BigInt::VERSION) >= 1.999827 };
  plan tests => 3704            # tests in require'd file
                 + 6;           # tests in this file
}

use Math::BigInt lib => 'LTM';

our ($CLASS, $CALC);
$CLASS = "Math::BigInt";
$CALC  = "Math::BigInt::LTM";

my $x;

#############################################################################
# from_hex(), from_bin() and from_oct() tests

$x = Math::BigInt->from_hex('0xcafe');
is($x, "51966",
   qq|Math::BigInt->from_hex("0xcafe")|);

$x = Math::BigInt->from_hex('0xcafebabedead');
is($x, "223195403574957",
   qq|Math::BigInt->from_hex("0xcafebabedead")|);

$x = Math::BigInt->from_bin('0b1001');
is($x, "9",
   qq|Math::BigInt->from_bin("0b1001")|);

$x = Math::BigInt->from_bin('0b1001100110011001100110011001');
is($x, "161061273",
   qq|Math::BigInt->from_bin("0b1001100110011001100110011001");|);

$x = Math::BigInt->from_oct('0775');
is($x, "509",
   qq|Math::BigInt->from_oct("0775");|);

$x = Math::BigInt->from_oct('07777777777777711111111222222222');
is($x, "9903520314281112085086151826",
   qq|Math::BigInt->from_oct("07777777777777711111111222222222");|);

#############################################################################
# all the other tests

require './t/mbi_ltm/bigintpm.inc';       # all tests here for sharing