From 6be90aec47b62d16b2264dd6be04b493dfe23364 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Wed, 10 Apr 2013 17:02:56 -0400 Subject: Rounded out the Scanner tests. --- test/HTML5/Parser/ScannerTest.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test/HTML5/Parser') diff --git a/test/HTML5/Parser/ScannerTest.php b/test/HTML5/Parser/ScannerTest.php index ad936df..1c9b009 100644 --- a/test/HTML5/Parser/ScannerTest.php +++ b/test/HTML5/Parser/ScannerTest.php @@ -121,4 +121,34 @@ class ScannerTest extends \HTML5\Tests\TestCase { $s->next(); $this->assertEquals('45', $s->getNumeric()); } + + public function testCurrentLine() { + $s = new Scanner(new StringInputStream("1784a\n45\n9867 #\nThis is a test.")); + + $this->assertEquals(1, $s->currentLine()); + + // Move to the next line. + $s->getAsciiAlphaNum(); $s->next(); + $this->assertEquals(2, $s->currentLine()); + } + + public function testColumnOffset() { + $s = new Scanner(new StringInputStream("1784a a\n45 9867 #\nThis is a test.")); + + // Move the pointer to the space. + $s->getAsciiAlphaNum(); + $this->assertEquals(5, $s->columnOffset()); + + // We move the pointer ahead. There must be a better way to do this. + $s->next(); $s->next(); $s->next(); $s->next(); $s->next(); $s->next(); + $this->assertEquals(3, $s->columnOffset()); + } + + public function testRemainingChars() { + $string = "\n45\n9867 #\nThis is a test."; + $s = new Scanner(new StringInputStream("1784a\n45\n9867 #\nThis is a test.")); + + $s->getAsciiAlphaNum(); + $this->assertEquals($string, $s->remainingChars()); + } } \ No newline at end of file -- cgit v1.2.3