ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
BigintTest\BigintTest Class Reference
+ Inheritance diagram for BigintTest\BigintTest:
+ Collaboration diagram for BigintTest\BigintTest:

Public Member Functions

 testConstruct ()
 
 testConstructLarge ()
 
 testAddSmallValue ()
 
 testAddWithOverflowAtLowestByte ()
 
 testAddWithOverflowAtInteger32 ()
 
 testAddWithOverflowAtInteger64 ()
 

Detailed Description

Definition at line 10 of file BigintTest.php.

Member Function Documentation

◆ testAddSmallValue()

BigintTest\BigintTest::testAddSmallValue ( )

Definition at line 28 of file BigintTest.php.

References ZipStream\Bigint\init().

28  : void
29  {
30  $bigint = new Bigint(1);
31  $bigint = $bigint->add(Bigint::init(2));
32  $this->assertSame(3, $bigint->getLow32());
33  $this->assertFalse($bigint->isOver32());
34  $this->assertTrue($bigint->isOver32(true));
35  $this->assertSame($bigint->getLowFF(), (float)$bigint->getLow32());
36  $this->assertSame($bigint->getLowFF(true), (float)0xFFFFFFFF);
37  }
static init(int $value=0)
Get an instance.
Definition: Bigint.php:47
+ Here is the call graph for this function:

◆ testAddWithOverflowAtInteger32()

BigintTest\BigintTest::testAddWithOverflowAtInteger32 ( )

Definition at line 46 of file BigintTest.php.

References ZipStream\Bigint\init().

46  : void
47  {
48  $bigint = new Bigint(0xFFFFFFFE);
49  $this->assertFalse($bigint->isOver32());
50  $bigint = $bigint->add(Bigint::init(0x01));
51  $this->assertTrue($bigint->isOver32());
52  $bigint = $bigint->add(Bigint::init(0x01));
53  $this->assertSame('0x0000000100000000', $bigint->getHex64());
54  $this->assertTrue($bigint->isOver32());
55  $this->assertSame((float)0xFFFFFFFF, $bigint->getLowFF());
56  }
static init(int $value=0)
Get an instance.
Definition: Bigint.php:47
+ Here is the call graph for this function:

◆ testAddWithOverflowAtInteger64()

BigintTest\BigintTest::testAddWithOverflowAtInteger64 ( )

Definition at line 58 of file BigintTest.php.

References ZipStream\Bigint\fromLowHigh(), and ZipStream\Bigint\init().

58  : void
59  {
60  $bigint = Bigint::fromLowHigh(0xFFFFFFFF, 0xFFFFFFFF);
61  $this->assertSame('0xFFFFFFFFFFFFFFFF', $bigint->getHex64());
62  $this->expectException(OverflowException::class);
63  $bigint->add(Bigint::init(1));
64  }
static init(int $value=0)
Get an instance.
Definition: Bigint.php:47
static fromLowHigh(int $low, int $high)
Fill bytes from low to high.
Definition: Bigint.php:59
+ Here is the call graph for this function:

◆ testAddWithOverflowAtLowestByte()

BigintTest\BigintTest::testAddWithOverflowAtLowestByte ( )

Definition at line 39 of file BigintTest.php.

References ZipStream\Bigint\init().

39  : void
40  {
41  $bigint = new Bigint(0xFF);
42  $bigint = $bigint->add(Bigint::init(0x01));
43  $this->assertSame(0x100, $bigint->getLow32());
44  }
static init(int $value=0)
Get an instance.
Definition: Bigint.php:47
+ Here is the call graph for this function:

◆ testConstruct()

BigintTest\BigintTest::testConstruct ( )

Definition at line 12 of file BigintTest.php.

12  : void
13  {
14  $bigint = new Bigint(0x12345678);
15  $this->assertSame('0x0000000012345678', $bigint->getHex64());
16  $this->assertSame(0x12345678, $bigint->getLow32());
17  $this->assertSame(0, $bigint->getHigh32());
18  }

◆ testConstructLarge()

BigintTest\BigintTest::testConstructLarge ( )

Definition at line 20 of file BigintTest.php.

20  : void
21  {
22  $bigint = new Bigint(0x87654321);
23  $this->assertSame('0x0000000087654321', $bigint->getHex64());
24  $this->assertSame('87654321', bin2hex(pack('N', $bigint->getLow32())));
25  $this->assertSame(0, $bigint->getHigh32());
26  }

The documentation for this class was generated from the following file: