summaryrefslogtreecommitdiff
path: root/test/rexml/test_notationdecl_parsetest.rb
blob: 27433c862600de11fc356739fa5d13ee7489e905 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require 'test/unit'
require 'rexml/document'

class TestNotationDecl < Test::Unit::TestCase
  private
  def xml(internal_subset)
    <<-XML
<!DOCTYPE r SYSTEM "urn:x-henrikmartensson:test" [
#{internal_subset}
]>
<r/>
    XML
  end

  def parse(internal_subset)
    REXML::Document.new(xml(internal_subset)).doctype
  end

  class TestCommon < self
    def test_name
      doctype = parse("<!NOTATION name PUBLIC 'urn:public-id'>")
      assert_equal("name", doctype.notation("name").name)
    end
  end

  class TestExternID < self
    class TestPublic < self
      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
    end
  end
end