Skip to content

Commit a6c2890

Browse files
author
Thomas Kerin
committed
Unit tests covering integer bit size values
1 parent 39502af commit a6c2890

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

tests/Types/IntegerBitSizeTest.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
namespace BitWasp\Buffertools\Tests\Types;
4+
5+
6+
use BitWasp\Buffertools\Tests\BinaryTest;
7+
use BitWasp\Buffertools\Types\Int128;
8+
use BitWasp\Buffertools\Types\Int16;
9+
use BitWasp\Buffertools\Types\Int256;
10+
use BitWasp\Buffertools\Types\Int32;
11+
use BitWasp\Buffertools\Types\Int64;
12+
use BitWasp\Buffertools\Types\Int8;
13+
use BitWasp\Buffertools\Types\SignedIntInterface;
14+
use BitWasp\Buffertools\Types\Uint128;
15+
use BitWasp\Buffertools\Types\Uint16;
16+
use BitWasp\Buffertools\Types\Uint256;
17+
use BitWasp\Buffertools\Types\Uint32;
18+
use BitWasp\Buffertools\Types\Uint64;
19+
use BitWasp\Buffertools\Types\Uint8;
20+
use BitWasp\Buffertools\Types\UintInterface;
21+
22+
class IntegerBitSizeTest extends BinaryTest
23+
{
24+
public function getClassAndBitSize()
25+
{
26+
return [
27+
[Uint8::class,8],
28+
[Uint16::class,16],
29+
[Uint32::class,32],
30+
[Uint64::class,64],
31+
[Uint128::class,128],
32+
[Uint256::class,256],
33+
[Int8::class,8],
34+
[Int16::class,16],
35+
[Int32::class,32],
36+
[Int64::class,64],
37+
[Int128::class,128],
38+
[Int256::class,256],
39+
];
40+
}
41+
42+
/**
43+
* @dataProvider getClassAndBitSize
44+
* @param string $integerClass
45+
* @param int $bitSize
46+
*/
47+
public function testBitSize(string $integerClass, int $bitSize) {
48+
/** @var UintInterface|SignedIntInterface $integer */
49+
$integer = new $integerClass();
50+
$this->assertEquals($bitSize, $integer->getBitSize());
51+
}
52+
}

0 commit comments

Comments
 (0)