From 72edbfa1678aa9d295562f3746291e32492abecb Mon Sep 17 00:00:00 2001 From: "Meredith L. Patterson" Date: Sat, 30 Nov 2013 16:58:27 -0800 Subject: [PATCH] so do h_right and h_middle --- src/bindings/php/Tests/MiddleTest.php | 36 +++++++++++++++++++++++++++ src/bindings/php/Tests/RightTest.php | 28 +++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 src/bindings/php/Tests/MiddleTest.php create mode 100644 src/bindings/php/Tests/RightTest.php diff --git a/src/bindings/php/Tests/MiddleTest.php b/src/bindings/php/Tests/MiddleTest.php new file mode 100644 index 0000000..c284b50 --- /dev/null +++ b/src/bindings/php/Tests/MiddleTest.php @@ -0,0 +1,36 @@ +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); + } +} +?> \ No newline at end of file diff --git a/src/bindings/php/Tests/RightTest.php b/src/bindings/php/Tests/RightTest.php new file mode 100644 index 0000000..c664251 --- /dev/null +++ b/src/bindings/php/Tests/RightTest.php @@ -0,0 +1,28 @@ +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); + } +} +?> \ No newline at end of file