2010-09-17 09:14:14 -04:00
|
|
|
require 'test/unit'
|
|
|
|
require 'rexml/document'
|
|
|
|
|
2013-07-31 10:00:26 -04:00
|
|
|
class TestParseNotationDeclaration < Test::Unit::TestCase
|
2013-07-31 08:32:24 -04:00
|
|
|
private
|
|
|
|
def xml(internal_subset)
|
|
|
|
<<-XML
|
|
|
|
<!DOCTYPE r SYSTEM "urn:x-henrikmartensson:test" [
|
|
|
|
#{internal_subset}
|
|
|
|
]>
|
|
|
|
<r/>
|
|
|
|
XML
|
2010-09-17 09:14:14 -04:00
|
|
|
end
|
|
|
|
|
2013-07-31 08:32:24 -04:00
|
|
|
def parse(internal_subset)
|
|
|
|
REXML::Document.new(xml(internal_subset)).doctype
|
|
|
|
end
|
2013-07-31 08:44:24 -04:00
|
|
|
|
|
|
|
class TestCommon < self
|
|
|
|
def test_name
|
|
|
|
doctype = parse("<!NOTATION name PUBLIC 'urn:public-id'>")
|
|
|
|
assert_equal("name", doctype.notation("name").name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-07-31 09:05:02 -04:00
|
|
|
class TestExternalID < self
|
2013-07-31 09:52:06 -04:00
|
|
|
class TestSystem < self
|
|
|
|
def test_single_quote
|
|
|
|
doctype = parse(<<-INTERNAL_SUBSET)
|
|
|
|
<!NOTATION name SYSTEM 'system-literal'>
|
|
|
|
INTERNAL_SUBSET
|
|
|
|
assert_equal("system-literal", doctype.notation("name").system)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_double_quote
|
|
|
|
doctype = parse(<<-INTERNAL_SUBSET)
|
|
|
|
<!NOTATION name SYSTEM "system-literal">
|
|
|
|
INTERNAL_SUBSET
|
|
|
|
assert_equal("system-literal", doctype.notation("name").system)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-07-31 08:59:28 -04:00
|
|
|
class TestPublic < self
|
2013-07-31 09:04:10 -04:00
|
|
|
class TestPublicIDLiteral < self
|
|
|
|
def test_single_quote
|
|
|
|
doctype = parse(<<-INTERNAL_SUBSET)
|
|
|
|
<!NOTATION name PUBLIC 'public-id-literal' "system-literal">
|
|
|
|
INTERNAL_SUBSET
|
2013-07-31 09:53:35 -04:00
|
|
|
assert_equal("public-id-literal", doctype.notation("name").public)
|
2013-07-31 09:04:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_double_quote
|
|
|
|
doctype = parse(<<-INTERNAL_SUBSET)
|
|
|
|
<!NOTATION name PUBLIC "public-id-literal" "system-literal">
|
|
|
|
INTERNAL_SUBSET
|
2013-07-31 09:53:35 -04:00
|
|
|
assert_equal("public-id-literal", doctype.notation("name").public)
|
2013-07-31 09:04:10 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-07-31 08:59:28 -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)
|
|
|
|
<!NOTATION name PUBLIC "public-id-literal" "system-literal">
|
|
|
|
INTERNAL_SUBSET
|
|
|
|
assert_equal("system-literal", doctype.notation("name").system)
|
|
|
|
end
|
|
|
|
end
|
2013-07-31 08:44:24 -04:00
|
|
|
end
|
|
|
|
end
|
2010-09-17 09:14:14 -04:00
|
|
|
end
|