2010-09-17 09:14:14 -04:00
|
|
|
require 'test/unit'
|
|
|
|
require 'rexml/document'
|
|
|
|
|
2014-05-27 08:07:40 -04:00
|
|
|
module REXMLTests
|
2014-05-27 09:10:55 -04:00
|
|
|
class TestParseNotationDeclaration < Test::Unit::TestCase
|
|
|
|
private
|
|
|
|
def xml(internal_subset)
|
|
|
|
<<-XML
|
2013-07-31 08:32:24 -04:00
|
|
|
<!DOCTYPE r SYSTEM "urn:x-henrikmartensson:test" [
|
|
|
|
#{internal_subset}
|
|
|
|
]>
|
|
|
|
<r/>
|
2014-05-27 09:10:55 -04:00
|
|
|
XML
|
2013-07-31 08:44:24 -04:00
|
|
|
end
|
|
|
|
|
2014-05-27 09:10:55 -04:00
|
|
|
def parse(internal_subset)
|
|
|
|
REXML::Document.new(xml(internal_subset)).doctype
|
|
|
|
end
|
2013-07-31 09:52:06 -04:00
|
|
|
|
2014-05-27 09:10:55 -04:00
|
|
|
class TestCommon < self
|
|
|
|
def test_name
|
|
|
|
doctype = parse("<!NOTATION name PUBLIC 'urn:public-id'>")
|
|
|
|
assert_equal("name", doctype.notation("name").name)
|
2013-07-31 09:52:06 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-05-27 09:10:55 -04:00
|
|
|
class TestExternalID < self
|
|
|
|
class TestSystem < self
|
2013-07-31 09:04:10 -04:00
|
|
|
def test_single_quote
|
|
|
|
doctype = parse(<<-INTERNAL_SUBSET)
|
2014-05-27 09:10:55 -04:00
|
|
|
<!NOTATION name SYSTEM 'system-literal'>
|
2013-07-31 09:04:10 -04:00
|
|
|
INTERNAL_SUBSET
|
2014-05-27 09:10:55 -04:00
|
|
|
assert_equal("system-literal", doctype.notation("name").system)
|
2013-07-31 09:04:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_double_quote
|
|
|
|
doctype = parse(<<-INTERNAL_SUBSET)
|
2014-05-27 09:10:55 -04:00
|
|
|
<!NOTATION name SYSTEM "system-literal">
|
2013-07-31 09:04:10 -04:00
|
|
|
INTERNAL_SUBSET
|
2014-05-27 09:10:55 -04:00
|
|
|
assert_equal("system-literal", doctype.notation("name").system)
|
2013-07-31 09:04:10 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-05-27 09:10:55 -04:00
|
|
|
class TestPublic < self
|
|
|
|
class TestPublicIDLiteral < self
|
|
|
|
def test_single_quote
|
|
|
|
doctype = parse(<<-INTERNAL_SUBSET)
|
|
|
|
<!NOTATION name PUBLIC 'public-id-literal' "system-literal">
|
|
|
|
INTERNAL_SUBSET
|
|
|
|
assert_equal("public-id-literal", doctype.notation("name").public)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_double_quote
|
|
|
|
doctype = parse(<<-INTERNAL_SUBSET)
|
|
|
|
<!NOTATION name PUBLIC "public-id-literal" "system-literal">
|
|
|
|
INTERNAL_SUBSET
|
|
|
|
assert_equal("public-id-literal", doctype.notation("name").public)
|
|
|
|
end
|
2013-07-31 08:59:28 -04:00
|
|
|
end
|
|
|
|
|
2014-05-27 09:10:55 -04:00
|
|
|
class TestSystemLiteral < self
|
|
|
|
def test_single_quote
|
|
|
|
doctype = parse(<<-INTERNAL_SUBSET)
|
|
|
|
<!NOTATION name PUBLIC "public-id-literal" 'system-literal'>
|
|
|
|
INTERNAL_SUBSET
|
|
|
|
assert_equal("system-literal", doctype.notation("name").system)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_double_quote
|
|
|
|
doctype = parse(<<-INTERNAL_SUBSET)
|
2013-07-31 08:59:28 -04:00
|
|
|
<!NOTATION name PUBLIC "public-id-literal" "system-literal">
|
2014-05-27 09:10:55 -04:00
|
|
|
INTERNAL_SUBSET
|
|
|
|
assert_equal("system-literal", doctype.notation("name").system)
|
|
|
|
end
|
2013-07-31 08:59:28 -04:00
|
|
|
end
|
|
|
|
end
|
2013-08-09 22:34:06 -04:00
|
|
|
|
2014-05-27 09:10:55 -04:00
|
|
|
class TestMixed < self
|
|
|
|
def test_system_public
|
|
|
|
doctype = parse(<<-INTERNAL_SUBSET)
|
2013-08-09 22:34:06 -04:00
|
|
|
<!NOTATION system-name SYSTEM "system-literal">
|
|
|
|
<!NOTATION public-name PUBLIC "public-id-literal" 'system-literal'>
|
2014-05-27 09:10:55 -04:00
|
|
|
INTERNAL_SUBSET
|
|
|
|
assert_equal(["system-name", "public-name"],
|
|
|
|
doctype.notations.collect(&:name))
|
|
|
|
end
|
2013-08-09 22:59:15 -04:00
|
|
|
|
2014-05-27 09:10:55 -04:00
|
|
|
def test_public_system
|
|
|
|
doctype = parse(<<-INTERNAL_SUBSET)
|
2013-08-09 22:59:15 -04:00
|
|
|
<!NOTATION public-name PUBLIC "public-id-literal" 'system-literal'>
|
|
|
|
<!NOTATION system-name SYSTEM "system-literal">
|
2014-05-27 09:10:55 -04:00
|
|
|
INTERNAL_SUBSET
|
|
|
|
assert_equal(["public-name", "system-name"],
|
|
|
|
doctype.notations.collect(&:name))
|
|
|
|
end
|
2013-08-09 22:59:15 -04:00
|
|
|
end
|
2013-08-09 22:34:06 -04:00
|
|
|
end
|
2013-07-31 08:44:24 -04:00
|
|
|
end
|
2010-09-17 09:14:14 -04:00
|
|
|
end
|