diff options
author | Matt Farina <[email protected]> | 2013-04-10 11:36:13 -0400 |
---|---|---|
committer | Matt Farina <[email protected]> | 2013-04-10 11:58:48 -0400 |
commit | eb0ea976ffc57aa3701e3e4cf6ce18375e9d10c2 (patch) | |
tree | bcb967b68bd4933b60da67e0013e2de07c9573ab | |
parent | 04fde93f07af13fdf5ddf5d5d539467135221d2a (diff) |
Added tests for the scanner getHex method.
-rw-r--r-- | src/HTML5/Parser/Scanner.php | 6 | ||||
-rw-r--r-- | test/HTML5/ScannerTest.php | 15 |
2 files changed, 8 insertions, 13 deletions
diff --git a/src/HTML5/Parser/Scanner.php b/src/HTML5/Parser/Scanner.php index 2500dab..77f14fb 100644 --- a/src/HTML5/Parser/Scanner.php +++ b/src/HTML5/Parser/Scanner.php @@ -86,15 +86,13 @@ class Scanner { } /** - * Get the next group of that is a hex value. + * Get the next group of that contains hex characters. * * Note, along with getting the characters the pointer in the data will be * moved as well. - * - * @todo There is a potential for many false positives with this method. Make it more accurate. * * @return string - * The next group that is a hex value. + * The next group that is hex characters. */ public function getHex() { return $this->is->charsWhile(self::CHARS_HEX); diff --git a/test/HTML5/ScannerTest.php b/test/HTML5/ScannerTest.php index 251dcfa..696b10e 100644 --- a/test/HTML5/ScannerTest.php +++ b/test/HTML5/ScannerTest.php @@ -82,17 +82,14 @@ class ScannerTest extends TestCase { $this->assertEquals($start, $s->position()); } - // public function testGetHex() { - // $s = new Scanner(new InputStream("abcdef%mnop*")); + public function testGetHex() { + $s = new Scanner(new InputStream("ab13ck45DE*")); - // $s->next(); + $this->assertEquals('ab13c', $s->getHex()); - // $this->assertEquals('bcdef', $s->getHex()); - - // echo $s->next(); echo $s->next(); echo $s->position(); echo $s->getHex(); - - // //$this->assertEquals('mnop', $s->getHex()); - // } + $s->next(); + $this->assertEquals('45DE', $s->getHex()); + } public function testGetAsciiAlpha() { $s = new Scanner(new InputStream("abcdef1%mnop*")); |