Skip to content

Commit

Permalink
Fix nest of test class
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed Jul 23, 2024
1 parent 9ecad7c commit 7c1c59d
Showing 1 changed file with 62 additions and 62 deletions.
124 changes: 62 additions & 62 deletions test/parse/test_entity_declaration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,110 +71,110 @@ def test_prohibited_character
valid-name \"% &\">]>
DETAIL
end
end

# https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-ExternalID
class TestExternalID < self
# https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-SystemLiteral
class TestSystemLiteral < self
def test_no_quote_in_system
exception = assert_raise(REXML::ParseException) do
REXML::Document.new('<!DOCTYPE root [<!ENTITY valid-name SYSTEM invalid-system-literal>]>')
end
assert_equal(<<-DETAIL.chomp, exception.to_s)
# https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-ExternalID
class TestExternalID < self
# https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-SystemLiteral
class TestSystemLiteral < self
def test_no_quote_in_system
exception = assert_raise(REXML::ParseException) do
REXML::Document.new('<!DOCTYPE root [<!ENTITY valid-name SYSTEM invalid-system-literal>]>')
end
assert_equal(<<-DETAIL.chomp, exception.to_s)
Malformed entity declaration
Line: 1
Position: 68
Last 80 unconsumed characters:
valid-name SYSTEM invalid-system-literal>]>
DETAIL
end
DETAIL
end

def test_no_quote_in_public
exception = assert_raise(REXML::ParseException) do
REXML::Document.new('<!DOCTYPE root [<!ENTITY valid-name PUBLIC "valid-pubid-literal" invalid-system-literal>]>')
end
assert_equal(<<-DETAIL.chomp, exception.to_s)
def test_no_quote_in_public
exception = assert_raise(REXML::ParseException) do
REXML::Document.new('<!DOCTYPE root [<!ENTITY valid-name PUBLIC "valid-pubid-literal" invalid-system-literal>]>')
end
assert_equal(<<-DETAIL.chomp, exception.to_s)
Malformed entity declaration
Line: 1
Position: 90
Last 80 unconsumed characters:
valid-name PUBLIC \"valid-pubid-literal\" invalid-system-literal>]>
DETAIL
end
DETAIL
end
end

# https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-PubidLiteral
# https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-PubidChar
class TestPublicIDLiteral < self
def test_no_quote
exception = assert_raise(REXML::ParseException) do
REXML::Document.new('<!DOCTYPE root [<!ENTITY valid-name PUBLIC invalid-pubid-literal "valid-system-literal">]>')
end
assert_equal(<<-DETAIL.chomp, exception.to_s)
# https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-PubidLiteral
# https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-PubidChar
class TestPublicIDLiteral < self
def test_no_quote
exception = assert_raise(REXML::ParseException) do
REXML::Document.new('<!DOCTYPE root [<!ENTITY valid-name PUBLIC invalid-pubid-literal "valid-system-literal">]>')
end
assert_equal(<<-DETAIL.chomp, exception.to_s)
Malformed entity declaration
Line: 1
Position: 90
Last 80 unconsumed characters:
valid-name PUBLIC invalid-pubid-literal \"valid-system-literal\">]>
DETAIL
end
DETAIL
end

def test_invalid_pubid_char
exception = assert_raise(REXML::ParseException) do
# U+3042 HIRAGANA LETTER A
REXML::Document.new("<!DOCTYPE root [<!ENTITY valid-name PUBLIC \"\u3042\" \"valid-system-literal\">]>")
end
assert_equal(<<-DETAIL.force_encoding('utf-8').chomp, exception.to_s.force_encoding('utf-8'))
def test_invalid_pubid_char
exception = assert_raise(REXML::ParseException) do
# U+3042 HIRAGANA LETTER A
REXML::Document.new("<!DOCTYPE root [<!ENTITY valid-name PUBLIC \"\u3042\" \"valid-system-literal\">]>")
end
assert_equal(<<-DETAIL.force_encoding('utf-8').chomp, exception.to_s.force_encoding('utf-8'))
Malformed entity declaration
Line: 1
Position: 74
Last 80 unconsumed characters:
valid-name PUBLIC \"\u3042\" \"valid-system-literal\">]>
DETAIL
end
DETAIL
end
end
end

# https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-NDataDecl
class TestNotationDataDeclaration < self
# https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-NameChar
def test_prohibited_character
exception = assert_raise(REXML::ParseException) do
REXML::Document.new('<!DOCTYPE root [<!ENTITY valid-name PUBLIC "valid-pubid-literal" "valid-system-literal" NDATA invalid&name>]>')
end
assert_equal(<<-DETAIL.chomp, exception.to_s)
# https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-NDataDecl
class TestNotationDataDeclaration < self
# https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-NameChar
def test_prohibited_character
exception = assert_raise(REXML::ParseException) do
REXML::Document.new('<!DOCTYPE root [<!ENTITY valid-name PUBLIC "valid-pubid-literal" "valid-system-literal" NDATA invalid&name>]>')
end
assert_equal(<<-DETAIL.chomp, exception.to_s)
Malformed entity declaration
Line: 1
Position: 109
Last 80 unconsumed characters:
valid-name PUBLIC \"valid-pubid-literal\" \"valid-system-literal\" NDATA invalid&nam
DETAIL
end
DETAIL
end
end
end
end

# https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-PEDecl
class TestParsedEntityDeclaration < self
# https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-PEDef
class TestParsedEntityDefinition < self
# https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-Name
class TestName < self
def test_prohibited_character
exception = assert_raise(REXML::ParseException) do
REXML::Document.new('<!DOCTYPE root [<!ENTITY % invalid&name "valid-entity-value">]>')
end
assert_equal(<<-DETAIL.chomp, exception.to_s)
# https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-Name
class TestName < self
def test_prohibited_character
exception = assert_raise(REXML::ParseException) do
REXML::Document.new('<!DOCTYPE root [<!ENTITY % invalid&name "valid-entity-value">]>')
end
assert_equal(<<-DETAIL.chomp, exception.to_s)
Malformed entity declaration
Line: 1
Position: 63
Last 80 unconsumed characters:
% invalid&name \"valid-entity-value\">]>
DETAIL
end
end
end

# https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-PEDef
class TestParsedEntityDefinition < self
# https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EntityValue
class TestEntityValue < self
def test_no_quote
Expand Down Expand Up @@ -266,19 +266,19 @@ def test_invalid_pubid_char
end
end
end
end

def test_unnecessary_ndata_declaration
exception = assert_raise(REXML::ParseException) do
REXML::Document.new('<!DOCTYPE root [<!ENTITY % valid-name "valid-entity-value" NDATA valid-ndata-value>]>')
end
assert_equal(<<-DETAIL.chomp, exception.to_s)
def test_unnecessary_ndata_declaration
exception = assert_raise(REXML::ParseException) do
REXML::Document.new('<!DOCTYPE root [<!ENTITY % valid-name "valid-entity-value" NDATA valid-ndata-value>]>')
end
assert_equal(<<-DETAIL.chomp, exception.to_s)
Malformed entity declaration
Line: 1
Position: 85
Last 80 unconsumed characters:
% valid-name \"valid-entity-value\" NDATA valid-ndata-value>]>
DETAIL
end
end
end

Expand Down

0 comments on commit 7c1c59d

Please sign in to comment.