-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathBitMaskTest.php
More file actions
50 lines (44 loc) · 1.26 KB
/
Copy pathBitMaskTest.php
File metadata and controls
50 lines (44 loc) · 1.26 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
<?php
namespace PhpBinaryReader;
/**
* @coversDefaultClass \PhpBinaryReader\BitMask
*/
class BitMaskTest extends \PHPUnit_Framework_TestCase
{
public function testBitMaskArray()
{
$expected = [
[0x00, 0xFF],
[0x01, 0x7F],
[0x03, 0x3F],
[0x07, 0x1F],
[0x0F, 0x0F],
[0x1F, 0x07],
[0x3F, 0x03],
[0x7F, 0x01],
[0xFF, 0x00]
];
$bitmask = new Bitmask();
$this->assertEquals($expected, $bitmask->getBitMasks());
}
public function testLoMaskIsReturnedByBit()
{
$bitmask = new Bitmask();
$this->assertEquals(0x03, $bitmask->getMask(2, BitMask::MASK_LO));
$this->assertEquals(0xFF, $bitmask->getMask(8, BitMask::MASK_LO));
}
public function testHiMaskIsReturnedByBit()
{
$bitmask = new Bitmask();
$this->assertEquals(0x03, $bitmask->getMask(6, BitMask::MASK_HI));
$this->assertEquals(0xFF, $bitmask->getMask(0, BitMask::MASK_HI));
}
/**
* @expectedException \PhpBinaryReader\Exception\InvalidDataException
*/
public function testExceptionIsThrownIfMaskTypeIsUnsupported()
{
$bitmask = new Bitmask();
$bitmask->getMask(5, 5);
}
}