From b55fd0628315705639ed96c22d05afd19a2f4e7c Mon Sep 17 00:00:00 2001 From: Andreu Correa Casablanca Date: Sat, 25 Feb 2017 17:21:14 +0100 Subject: [PATCH] Increase testing coverage --- tests/GUID/fromBinaryStringTest.php | 2 +- tests/GUID/fromHexStringTest.php | 2 +- tests/GUID/numBitsTest.php | 69 +++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 tests/GUID/numBitsTest.php diff --git a/tests/GUID/fromBinaryStringTest.php b/tests/GUID/fromBinaryStringTest.php index a24fe73..6fe4338 100644 --- a/tests/GUID/fromBinaryStringTest.php +++ b/tests/GUID/fromBinaryStringTest.php @@ -11,7 +11,7 @@ * @covers \Unicity\GUID::__construct * @covers \Unicity\GUID::fromBinaryString */ -class fromBinaryStringTestTest extends TestCase +class fromBinaryStringTest extends TestCase { /** * @expectedException \Unicity\Errors\GUIDInvariantsViolationError diff --git a/tests/GUID/fromHexStringTest.php b/tests/GUID/fromHexStringTest.php index 5b1be46..dcacf50 100644 --- a/tests/GUID/fromHexStringTest.php +++ b/tests/GUID/fromHexStringTest.php @@ -11,7 +11,7 @@ * @covers \Unicity\GUID::__construct * @covers \Unicity\GUID::fromHexString */ -class fromHexStringTestTest extends TestCase +class fromHexStringTest extends TestCase { /** * @expectedException \Unicity\Errors\GUIDInvariantsViolationError diff --git a/tests/GUID/numBitsTest.php b/tests/GUID/numBitsTest.php new file mode 100644 index 0000000..139ee10 --- /dev/null +++ b/tests/GUID/numBitsTest.php @@ -0,0 +1,69 @@ +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] + ]; + } +} \ No newline at end of file