diff options
author | Technosophos <[email protected]> | 2013-04-10 17:05:51 -0500 |
---|---|---|
committer | Technosophos <[email protected]> | 2013-04-10 17:05:51 -0500 |
commit | 36ff33f79ce45f9080ce88b9750a9009868a9a13 (patch) | |
tree | 45123de4b8803f217d256019da2dbb84d0d6c54b | |
parent | 2c93650ebf6b8f945f6a48f36ac096c9abacbf40 (diff) |
Added character reference test.
-rw-r--r-- | test/HTML5/Parser/CharacterReferenceTest.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/HTML5/Parser/CharacterReferenceTest.php b/test/HTML5/Parser/CharacterReferenceTest.php new file mode 100644 index 0000000..bb9b393 --- /dev/null +++ b/test/HTML5/Parser/CharacterReferenceTest.php @@ -0,0 +1,38 @@ +<?php +/** + * @file + * Test the Scanner. This requires the InputStream tests are all good. + */ +namespace HTML5\Parser; + +require_once __DIR__ . '/../TestCase.php'; + +class CharacterReferenceTest extends \HTML5\Tests\TestCase { + public function testLookupName() { + $this->assertEquals('&', CharacterReference::lookupName('amp')); + $this->assertEquals('<', CharacterReference::lookupName('lt')); + $this->assertEquals('>', CharacterReference::lookupName('gt')); + $this->assertEquals('"', CharacterReference::lookupName('quot')); + $this->assertEquals('∌', CharacterReference::lookupName('NotReverseElement')); + } + + public function testLookupHex() { + $this->assertEquals('<', CharacterReference::lookupHex('3c')); + $this->assertEquals('<', CharacterReference::lookupHex('003c')); + $this->assertEquals('&', CharacterReference::lookupHex('26')); + $this->assertEquals('}', CharacterReference::lookupHex('7d')); + $this->assertEquals('Σ', CharacterReference::lookupHex('3A3')); + $this->assertEquals('Σ', CharacterReference::lookupHex('03A3')); + $this->assertEquals('Σ', CharacterReference::lookupHex('3a3')); + $this->assertEquals('Σ', CharacterReference::lookupHex('03a3')); + } + + public function testLookupDecimal() { + $this->assertEquals('&', CharacterReference::lookupDecimal(38)); + $this->assertEquals('&', CharacterReference::lookupDecimal('38')); + $this->assertEquals('<', CharacterReference::lookupDecimal(60)); + $this->assertEquals('Σ', CharacterReference::lookupDecimal(931)); + $this->assertEquals('Σ', CharacterReference::lookupDecimal('0931')); + } + +} |