From fcbf63e62c627deae76c1b8cb8c0876c536ed811 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Mon, 16 Mar 2020 18:49:26 +0900 Subject: Fresh start --- .../rexml/parse/test_document_type_declaration.rb | 49 +++++++++++ .../test/rexml/parse/test_notation_declaration.rb | 99 ++++++++++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 jni/ruby/test/rexml/parse/test_document_type_declaration.rb create mode 100644 jni/ruby/test/rexml/parse/test_notation_declaration.rb (limited to 'jni/ruby/test/rexml/parse') diff --git a/jni/ruby/test/rexml/parse/test_document_type_declaration.rb b/jni/ruby/test/rexml/parse/test_document_type_declaration.rb new file mode 100644 index 0000000..59fe561 --- /dev/null +++ b/jni/ruby/test/rexml/parse/test_document_type_declaration.rb @@ -0,0 +1,49 @@ +require "test/unit" +require "rexml/document" + +module REXMLTests + class TestParseDocumentTypeDeclaration < Test::Unit::TestCase + private + def xml(internal_subset) + <<-XML + + + 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) + + + INTERNAL_SUBSET + assert_equal([REXML::Entity, REXML::ElementDecl], + doctype.children.collect(&:class)) + end + + def test_attlist_entity + doctype = parse(<<-INTERNAL_SUBSET) + + + INTERNAL_SUBSET + assert_equal([REXML::AttlistDecl, REXML::Entity], + doctype.children.collect(&:class)) + end + + def test_notation_attlist + doctype = parse(<<-INTERNAL_SUBSET) + + + INTERNAL_SUBSET + assert_equal([REXML::NotationDecl, REXML::AttlistDecl], + doctype.children.collect(&:class)) + end + end + end +end diff --git a/jni/ruby/test/rexml/parse/test_notation_declaration.rb b/jni/ruby/test/rexml/parse/test_notation_declaration.rb new file mode 100644 index 0000000..0a4e737 --- /dev/null +++ b/jni/ruby/test/rexml/parse/test_notation_declaration.rb @@ -0,0 +1,99 @@ +require 'test/unit' +require 'rexml/document' + +module REXMLTests + class TestParseNotationDeclaration < Test::Unit::TestCase + private + def xml(internal_subset) + <<-XML + + + XML + end + + def parse(internal_subset) + REXML::Document.new(xml(internal_subset)).doctype + end + + class TestCommon < self + def test_name + doctype = parse("") + assert_equal("name", doctype.notation("name").name) + end + end + + class TestExternalID < self + class TestSystem < self + def test_single_quote + doctype = parse(<<-INTERNAL_SUBSET) + + INTERNAL_SUBSET + assert_equal("system-literal", doctype.notation("name").system) + end + + def test_double_quote + doctype = parse(<<-INTERNAL_SUBSET) + + INTERNAL_SUBSET + assert_equal("system-literal", doctype.notation("name").system) + end + end + + class TestPublic < self + class TestPublicIDLiteral < self + def test_single_quote + doctype = parse(<<-INTERNAL_SUBSET) + + INTERNAL_SUBSET + assert_equal("public-id-literal", doctype.notation("name").public) + end + + def test_double_quote + doctype = parse(<<-INTERNAL_SUBSET) + + INTERNAL_SUBSET + assert_equal("public-id-literal", doctype.notation("name").public) + end + end + + class TestSystemLiteral < self + def test_single_quote + doctype = parse(<<-INTERNAL_SUBSET) + + INTERNAL_SUBSET + assert_equal("system-literal", doctype.notation("name").system) + end + + def test_double_quote + doctype = parse(<<-INTERNAL_SUBSET) + + INTERNAL_SUBSET + assert_equal("system-literal", doctype.notation("name").system) + end + end + end + + class TestMixed < self + def test_system_public + doctype = parse(<<-INTERNAL_SUBSET) + + + INTERNAL_SUBSET + assert_equal(["system-name", "public-name"], + doctype.notations.collect(&:name)) + end + + def test_public_system + doctype = parse(<<-INTERNAL_SUBSET) + + + INTERNAL_SUBSET + assert_equal(["public-name", "system-name"], + doctype.notations.collect(&:name)) + end + end + end + end +end -- cgit v1.2.3-70-g09d2