unsigned ints working too
This commit is contained in:
parent
b13d5045e2
commit
c89f3dc7c7
4 changed files with 96 additions and 0 deletions
24
src/bindings/php/Tests/Uint16Test.php
Normal file
24
src/bindings/php/Tests/Uint16Test.php
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
include_once 'hammer.php';
|
||||||
|
|
||||||
|
class Uint16Test extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
protected $parser;
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
$this->parser = h_uint16();
|
||||||
|
}
|
||||||
|
public function testSuccess()
|
||||||
|
{
|
||||||
|
$result = h_parse($this->parser, "\x02\x00");
|
||||||
|
$this->assertEquals(0x200, $result);
|
||||||
|
}
|
||||||
|
public function testFailure()
|
||||||
|
{
|
||||||
|
$result = h_parse($this->parser, "\x02");
|
||||||
|
$this->assertEquals(NULL, $result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
24
src/bindings/php/Tests/Uint32Test.php
Normal file
24
src/bindings/php/Tests/Uint32Test.php
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
include_once 'hammer.php';
|
||||||
|
|
||||||
|
class Uint32Test extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
protected $parser;
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
$this->parser = h_uint32();
|
||||||
|
}
|
||||||
|
public function testSuccess()
|
||||||
|
{
|
||||||
|
$result = h_parse($this->parser, "\x00\x02\x00\x00");
|
||||||
|
$this->assertEquals(0x20000, $result);
|
||||||
|
}
|
||||||
|
public function testFailure()
|
||||||
|
{
|
||||||
|
$result = h_parse($this->parser, "\x00\x02\x00");
|
||||||
|
$this->assertEquals(NULL, $result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
24
src/bindings/php/Tests/Uint64Test.php
Normal file
24
src/bindings/php/Tests/Uint64Test.php
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
include_once 'hammer.php';
|
||||||
|
|
||||||
|
class Uint64Test extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
protected $parser;
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
$this->parser = h_uint64();
|
||||||
|
}
|
||||||
|
public function testSuccess()
|
||||||
|
{
|
||||||
|
$result = h_parse($this->parser, "\x00\x00\x00\x02\x00\x00\x00\x00");
|
||||||
|
$this->assertEquals(0x200000000, $result);
|
||||||
|
}
|
||||||
|
public function testFailure()
|
||||||
|
{
|
||||||
|
$result = h_parse($this->parser, "\x00\x00\x00\x02\x00\x00\x00");
|
||||||
|
$this->assertEquals(NULL, $result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
24
src/bindings/php/Tests/Uint8Test.php
Normal file
24
src/bindings/php/Tests/Uint8Test.php
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
include_once 'hammer.php';
|
||||||
|
|
||||||
|
class Uint8Test extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
protected $parser;
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
$this->parser = h_uint8();
|
||||||
|
}
|
||||||
|
public function testSuccess()
|
||||||
|
{
|
||||||
|
$result = h_parse($this->parser, "\x78");
|
||||||
|
$this->assertEquals(0x78, $result);
|
||||||
|
}
|
||||||
|
public function testFailure()
|
||||||
|
{
|
||||||
|
$result = h_parse($this->parser, "");
|
||||||
|
$this->assertEquals(NULL, $result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue