-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathStrTest.php
More file actions
87 lines (75 loc) · 2.14 KB
/
Copy pathStrTest.php
File metadata and controls
87 lines (75 loc) · 2.14 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
namespace PhpBinaryReader\Type;
use PhpBinaryReader\AbstractTestCase;
use PhpBinaryReader\BinaryReader;
use PhpBinaryReader\Endian;
/**
* @coversDefaultClass \PhpBinaryReader\Type\Str
*/
class StrTest extends AbstractTestCase
{
/**
* @var Str
*/
public $string;
public function setUp()
{
$this->string = new Str();
}
/**
* @dataProvider binaryReaders
*/
public function testStringIsRead($brBig, $brLittle)
{
$brBig->setPosition(7);
$brLittle->setPosition(7);
$this->assertEquals('test!', $this->string->read($brBig, 5));
$this->assertEquals('test!', $this->string->read($brLittle, 5));
}
/**
* @dataProvider binaryReaders
*/
public function testAlignedStringIsRead($brBig, $brLittle)
{
$brBig->setPosition(6);
$brLittle->setPosition(6);
$brBig->readBits(1);
$brLittle->readBits(1);
$this->assertEquals('test!', $this->string->readAligned($brBig, 5));
$this->assertEquals('test!', $this->string->readAligned($brLittle, 5));
}
/**
* @expectedException \OutOfBoundsException
* @dataProvider binaryReaders
*/
public function testExceptionIsThrownIfOutOfBoundsBigEndian($brBig, $brLittle)
{
$brBig->readBits(360);
$this->string->read($brBig, 1);
}
/**
* @expectedException \OutOfBoundsException
* @dataProvider binaryReaders
*/
public function testExceptionIsThrownIfOutOfBoundsLittleEndian($brBig, $brLittle)
{
$brLittle->readBits(360);
$this->string->read($brLittle, 1);
}
/**
* @expectedException \PhpBinaryReader\Exception\InvalidDataException
* @dataProvider binaryReaders
*/
public function testExceptionIsThrownIfLengthIsInvalidBigEndian($brBig, $brLittle)
{
$this->string->read($brBig, 'foo');
}
/**
* @expectedException \PhpBinaryReader\Exception\InvalidDataException
* @dataProvider binaryReaders
*/
public function testExceptionIsThrownIfLengthIsInvalidLittleEndian($brBig, $brLittle)
{
$this->string->read($brBig, 'foo');
}
}