so do h_right and h_middle
This commit is contained in:
parent
596d619fb5
commit
72edbfa167
2 changed files with 64 additions and 0 deletions
36
src/bindings/php/Tests/MiddleTest.php
Normal file
36
src/bindings/php/Tests/MiddleTest.php
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
include_once 'hammer.php';
|
||||||
|
|
||||||
|
class MiddleTest extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
protected $parser;
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
$this->parser = h_middle(h_ch(" "), h_ch("a"), h_ch(" "));
|
||||||
|
}
|
||||||
|
public function testSuccess()
|
||||||
|
{
|
||||||
|
$result = h_parse($this->parser, " a ");
|
||||||
|
// TODO fix these tests when h_ch is fixed
|
||||||
|
$this->assertEquals(97, $result);
|
||||||
|
}
|
||||||
|
public function testFailure()
|
||||||
|
{
|
||||||
|
$result1 = h_parse($this->parser, "a");
|
||||||
|
$result2 = h_parse($this->parser, " ");
|
||||||
|
$result3 = h_parse($this->parser, " a");
|
||||||
|
$result4 = h_parse($this->parser, "a ");
|
||||||
|
$result5 = h_parse($this->parser, " b ");
|
||||||
|
$result6 = h_parse($this->parser, "ba ");
|
||||||
|
$result7 = h_parse($this->parser, " ab");
|
||||||
|
$this->assertEquals(NULL, $result1);
|
||||||
|
$this->assertEquals(NULL, $result2);
|
||||||
|
$this->assertEquals(NULL, $result3);
|
||||||
|
$this->assertEquals(NULL, $result4);
|
||||||
|
$this->assertEquals(NULL, $result5);
|
||||||
|
$this->assertEquals(NULL, $result6);
|
||||||
|
$this->assertEquals(NULL, $result7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
28
src/bindings/php/Tests/RightTest.php
Normal file
28
src/bindings/php/Tests/RightTest.php
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
include_once 'hammer.php';
|
||||||
|
|
||||||
|
class RightTest extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
protected $parser;
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
$this->parser = h_right(h_ch(" "), h_ch("a"));
|
||||||
|
}
|
||||||
|
public function testSuccess()
|
||||||
|
{
|
||||||
|
$result = h_parse($this->parser, " a");
|
||||||
|
// TODO fix these tests when h_ch is fixed
|
||||||
|
$this->assertEquals(97, $result);
|
||||||
|
}
|
||||||
|
public function testFailure()
|
||||||
|
{
|
||||||
|
$result1 = h_parse($this->parser, "a");
|
||||||
|
$result2 = h_parse($this->parser, " ");
|
||||||
|
$result3 = h_parse($this->parser, "ba");
|
||||||
|
$this->assertEquals(NULL, $result1);
|
||||||
|
$this->assertEquals(NULL, $result2);
|
||||||
|
$this->assertEquals(NULL, $result3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue