Browse Source

skips of tests on x32 CPUs added

pull/8/head
Paul Rock 7 years ago
parent
commit
34820dc564
  1. 35
      tests/APILengthCoDecTest.php
  2. 22
      tests/Helpers/BinaryStringHelperTest.php

35
tests/APILengthCoDecTest.php

@ -62,7 +62,26 @@ class APILengthCoDecTest extends TestCase
[0xE0200000, 0x200000], // Low limit value for 4 bytes encoded length
[0xE5AD736B, 0x5AD736B], // Arbitrary median value for 4 bytes encoded length
[0xEFFFFFFF, 0xFFFFFFF], // High limit value for 4 bytes encoded length
];
}
/**
* @dataProvider encodedLengthProvider64
* @covers ::encodeLength
*/
public function test__encodeLength64($expected, $length)
{
if (PHP_INT_SIZE < 8) {
$this->markTestSkipped('Available only on x64 CPUs');
}
$this->assertEquals(BinaryStringHelper::IntegerToNBOBinaryString((int) $expected), APILengthCoDec::encodeLength($length));
}
public function encodedLengthProvider64(): array
{
// [encoded length value, length value]
return [
[0xF010000000, 0x10000000], // Low limit value for 5 bytes encoded length
[0xF10D4EF9C3, 0x10D4EF9C3], // Arbitrary median value for 5 bytes encoded length
[0xF7FFFFFFFF, 0x7FFFFFFFF], // High limit value for 5 bytes encoded length
@ -73,7 +92,6 @@ class APILengthCoDecTest extends TestCase
* @dataProvider encodedLengthProvider
* @covers ::decodeLength
*/
public function test__decodeLength($encodedLength, $expected)
{
// We have to provide $encodedLength as a "bytes" stream
@ -82,6 +100,21 @@ class APILengthCoDecTest extends TestCase
}
/**
* @dataProvider encodedLengthProvider64
* @covers ::decodeLength
*/
public function test__decodeLength64($encodedLength, $expected)
{
if (PHP_INT_SIZE < 8) {
$this->markTestSkipped('Available only on x64 CPUs');
}
// We have to provide $encodedLength as a "bytes" stream
$stream = new StringStream(BinaryStringHelper::IntegerToNBOBinaryString($encodedLength));
$this->assertEquals($expected, APILengthCoDec::decodeLength($stream));
}
/**
* @dataProvider decodeLengthControlWordProvider
* @covers ::decodeLength
* @expectedException \UnexpectedValueException

22
tests/Helpers/BinaryStringHelperTest.php

@ -42,4 +42,26 @@ class BinaryStringHelperTest extends TestCase
[0x390DDD99, chr(0x39) . chr(0x0D) . chr(0xDD) . chr(0x99)],
];
}
/**
* @dataProvider IntegerToNBOBinaryStringProvider64
* @covers ::IntegerToNBOBinaryString
*/
public function test__IntegerToNBOBinaryString64($value, $expected)
{
if (PHP_INT_SIZE < 8) {
$this->markTestSkipped('Available only on x64 CPUs');
}
$this->assertEquals($expected, BinaryStringHelper::IntegerToNBOBinaryString($value));
}
public function IntegerToNBOBinaryStringProvider64(): array
{
return [
// -1 is encoded with 0xFFFFFFF.....
// 64 bits maximal value (on a 64 bits system only)
[-1, chr(0xFF) . chr(0xFF) . chr(0xFF) . chr(0xFF) . chr(0xFF) . chr(0xFF) . chr(0xFF) . chr(0xFF)], // 64 bits upper boundary value
];
}
}
Loading…
Cancel
Save