-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathByteTest.php
More file actions
73 lines (63 loc) · 1.73 KB
/
Copy pathByteTest.php
File metadata and controls
73 lines (63 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
namespace PhpBinaryReader\Type;
use PhpBinaryReader\AbstractTestCase;
use PhpBinaryReader\BinaryReader;
use PhpBinaryReader\Endian;
/**
* @coversDefaultClass \PhpBinaryReader\Type\Byte
*/
class ByteTest extends AbstractTestCase
{
/**
* @var Byte
*/
public $byte;
public function setUp()
{
$this->byte = new Byte();
}
/**
* @dataProvider binaryReaders
*/
public function testBytesAreRead($brBig, $brLittle)
{
$brBig->setPosition(7);
$brLittle->setPosition(7);
$this->assertEquals('test!', $this->byte->read($brBig, 5));
$this->assertEquals('test!', $this->byte->read($brLittle, 5));
}
/**
* @expectedException \OutOfBoundsException
* @dataProvider binaryReaders
*/
public function testExceptionIsThrownIfOutOfBoundsBigEndian($brBig, $brLittle)
{
$brBig->readBits(360);
$this->byte->read($brBig, 1);
}
/**
* @expectedException \OutOfBoundsException
* @dataProvider binaryReaders
*/
public function testExceptionIsThrownIfOutOfBoundsLittleEndian($brBig, $brLittle)
{
$brLittle->readBits(360);
$this->byte->read($brLittle, 1);
}
/**
* @expectedException \PhpBinaryReader\Exception\InvalidDataException
* @dataProvider binaryReaders
*/
public function testExceptionIsThrownIfLengthIsInvalidBigEndian($brBig, $brLittle)
{
$this->byte->read($brBig, 'foo');
}
/**
* @expectedException \PhpBinaryReader\Exception\InvalidDataException
* @dataProvider binaryReaders
*/
public function testExceptionIsThrownIfLengthIsInvalidLittleEndian($brBig, $brLittle)
{
$this->byte->read($brBig, 'foo');
}
}