@ -11,6 +11,7 @@ use RouterOS\Helpers\BinaryStringHelper;
/**
/**
* Limit code coverage to the class
* Limit code coverage to the class
*
* @ coversDefaultClass \RouterOS\APILengthCoDec
* @ coversDefaultClass \RouterOS\APILengthCoDec
*/
*/
class APILengthCoDecTest extends TestCase
class APILengthCoDecTest extends TestCase
@ -25,11 +26,11 @@ class APILengthCoDecTest extends TestCase
APILengthCoDec :: encodeLength ( $length );
APILengthCoDec :: encodeLength ( $length );
}
}
public function encodeLengthNegativeProvider ()
public function encodeLengthNegativeProvider () : array
{
{
return [
return [
[ - 1 ],
[ PHP_INT_MIN ],
[ - 1 ],
[ PHP_INT_MIN ],
];
];
}
}
@ -39,10 +40,10 @@ class APILengthCoDecTest extends TestCase
*/
*/
public function test__encodeLength ( $expected , $length )
public function test__encodeLength ( $expected , $length )
{
{
$this -> assertEquals ( BinaryStringHelper :: IntegerToNBOBinaryString ( $expected ), APILengthCoDec :: encodeLength ( $length ));
$this -> assertEquals ( BinaryStringHelper :: IntegerToNBOBinaryString (( int ) $expected ), APILengthCoDec :: encodeLength ( $length ));
}
}
public function encodedLengthProvider ()
public function encodedLengthProvider () : array
{
{
// [encoded length value, length value]
// [encoded length value, length value]
return [
return [
@ -54,14 +55,14 @@ class APILengthCoDecTest extends TestCase
[ 0x9C42 , 0x1C42 ], // Arbitrary median value for 2 bytes encoded length
[ 0x9C42 , 0x1C42 ], // Arbitrary median value for 2 bytes encoded length
[ 0xBFFF , 0x3FFF ], // High limit value for 2 bytes encoded length
[ 0xBFFF , 0x3FFF ], // High limit value for 2 bytes encoded length
[ 0xC04000 , 0x4000 ], // Low limit value for 3 bytesv
[ 0xC04000 , 0x4000 ], // Low limit value for 3 bytes
[ 0xCAD73B , 0xAD73B ], // Arbitrary median value for 3 bytes encoded length
[ 0xCAD73B , 0xAD73B ], // Arbitrary median value for 3 bytes encoded length
[ 0xDFFFFF , 0x1FFFFF ], // High limit value for 3 bytes encoded length
[ 0xDFFFFF , 0x1FFFFF ], // High limit value for 3 bytes encoded length
[ 0xE0200000 , 0x200000 ], // Low limit value for 4 bytes encoded length
[ 0xE0200000 , 0x200000 ], // Low limit value for 4 bytes encoded length
[ 0xE5AD736B , 0x5AD736B ], // Arbitrary median 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
[ 0xEFFFFFFF , 0xFFFFFFF ], // High limit value for 4 bytes encoded length
[ 0xF010000000 , 0x10000000 ], // Low limit value for 5 bytes encoded length
[ 0xF010000000 , 0x10000000 ], // Low limit value for 5 bytes encoded length
[ 0xF10D4EF9C3 , 0x10D4EF9C3 ], // Arbitrary median 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
[ 0xF7FFFFFFFF , 0x7FFFFFFFF ], // High limit value for 5 bytes encoded length
@ -83,19 +84,19 @@ class APILengthCoDecTest extends TestCase
/**
/**
* @ dataProvider decodeLengthControlWordProvider
* @ dataProvider decodeLengthControlWordProvider
* @ covers :: decodeLength
* @ covers :: decodeLength
* @ expectedException UnexpectedValueException
* @ expectedException \ UnexpectedValueException
*/
*/
public function test_decodeLengthControlWord ( string $encodedLength )
public function test_decodeLengthControlWord ( string $encodedLength )
{
{
APILengthCoDec :: decodeLength ( new StringStream ( $encodedLength ));
APILengthCoDec :: decodeLength ( new StringStream ( $encodedLength ));
}
}
public function decodeLengthControlWordProvider ()
{
// Control bytes : 5 most signficants its sets to 1
public function decodeLengthControlWordProvider () : array
{
// Control bytes: 5 most significance its sets to 1
return [
return [
[ chr ( 0xF8 )], // minimum
[ chr ( 0xF8 )], // minimum
[ chr ( 0xFC )], // arbitrat y value
[ chr ( 0xFC )], // arbitrar y value
[ chr ( 0xFF )], // maximum
[ chr ( 0xFF )], // maximum
];
];
}
}