1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* test/rexml/parse/test_document_type_declaration.rb: Add tests for

parsing document type declaration.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kou 2013-08-10 03:40:58 +00:00
parent 122f5c376b
commit 8a4567b207
2 changed files with 52 additions and 0 deletions

View file

@ -1,3 +1,8 @@
Sat Aug 10 12:39:00 2013 Kouhei Sutou <kou@cozmixng.org>
* test/rexml/parse/test_document_type_declaration.rb: Add tests for
parsing document type declaration.
Sat Aug 10 12:00:45 2013 Kouhei Sutou <kou@cozmixng.org>
* lib/rexml/parsers/baseparser.rb (REXML::Parsers::BaseParser::SYSTEM):

View file

@ -0,0 +1,47 @@
require "test/unit"
require "rexml/document"
class TestParseDocumentTypeDeclaration < Test::Unit::TestCase
private
def xml(internal_subset)
<<-XML
<!DOCTYPE r SYSTEM "urn:x-rexml:test" [
#{internal_subset}
]>
<r/>
XML
end
def parse(internal_subset)
REXML::Document.new(xml(internal_subset)).doctype
end
class TestMixed < self
def test_entity_element
doctype = parse(<<-INTERNAL_SUBSET)
<!ENTITY entity-name "entity content">
<!ELEMENT element-name EMPTY>
INTERNAL_SUBSET
assert_equal([REXML::Entity, REXML::ElementDecl],
doctype.children.collect(&:class))
end
def test_attlist_entity
doctype = parse(<<-INTERNAL_SUBSET)
<!ATTLIST attribute-list-name attribute-name CDATA #REQUIRED>
<!ENTITY entity-name "entity content">
INTERNAL_SUBSET
assert_equal([REXML::AttlistDecl, REXML::Entity],
doctype.children.collect(&:class))
end
def test_notation_attlist
doctype = parse(<<-INTERNAL_SUBSET)
<!NOTATION notation-name SYSTEM "system-literal">
<!ATTLIST attribute-list-name attribute-name CDATA #REQUIRED>
INTERNAL_SUBSET
assert_equal([REXML::NotationDecl, REXML::AttlistDecl],
doctype.children.collect(&:class))
end
end
end