Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
Increase testing coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
castarco committed Feb 25, 2017
1 parent f9423d3 commit b55fd06
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/GUID/fromBinaryStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @covers \Unicity\GUID::__construct
* @covers \Unicity\GUID::fromBinaryString
*/
class fromBinaryStringTestTest extends TestCase
class fromBinaryStringTest extends TestCase
{
/**
* @expectedException \Unicity\Errors\GUIDInvariantsViolationError
Expand Down
2 changes: 1 addition & 1 deletion tests/GUID/fromHexStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @covers \Unicity\GUID::__construct
* @covers \Unicity\GUID::fromHexString
*/
class fromHexStringTestTest extends TestCase
class fromHexStringTest extends TestCase
{
/**
* @expectedException \Unicity\Errors\GUIDInvariantsViolationError
Expand Down
69 changes: 69 additions & 0 deletions tests/GUID/numBitsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php
declare(strict_types=1);

namespace Unicity\Tests\GUID;

use PHPUnit\Framework\TestCase;
use Unicity\GUID;

/**
* @covers \Unicity\GUID::numBits
*/
class numBitsTest extends TestCase
{
/**
* @param string $hexString
* @param int $numBits
*
* @dataProvider hexStringsProvider
*/
public function testNumBitsFromHexString(string $hexString, int $numBits)
{
$this->assertEquals($numBits, GUID::fromHexString($hexString, $numBits / 8)->numBits());
}

/**
* @param string $b64String
* @param int $numBits
*
* @dataProvider b64StringsProvider
*/
public function testNumBitsFromBase64String(string $b64String, int $numBits)
{
$this->assertEquals($numBits, GUID::fromBase64String($b64String, $numBits / 8)->numBits());
}

public function hexStringsProvider(): array
{
return [
['0123456789ab', 48],
['0123456789abcd', 56],
['0123456789abcdef', 64],
['0123456789abcdef01', 72],
['0123456789abcdef0123', 80],
['0123456789abcdef012345', 88],
['0123456789abcdef01234567', 96],
['0123456789abcdef0123456789', 104],
['0123456789abcdef0123456789ab', 112],
['0123456789abcdef0123456789abcd', 120],
['0123456789abcdef0123456789abcdef', 128]
];
}

public function b64StringsProvider(): array
{
return [
["ASNFZ4mr", 48],
["ASNFZ4mrzQ==", 56],
["ASNFZ4mrze8=", 64],
["ASNFZ4mrze8B", 72],
["ASNFZ4mrze8BIw==", 80],
["ASNFZ4mrze8BI0U=", 88],
["ASNFZ4mrze8BI0Vn", 96],
["ASNFZ4mrze8BI0VniQ==", 104],
["ASNFZ4mrze8BI0Vnias=", 112],
["ASNFZ4mrze8BI0VniavN", 120],
["ASNFZ4mrze8BI0VniavN7w==", 128]
];
}
}

0 comments on commit b55fd06

Please sign in to comment.