Skip to content

Commit

Permalink
Add tests for no literal case
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed Jul 23, 2024
1 parent 7e95837 commit 8b42c31
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions test/parse/test_entity_declaration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,32 @@ def test_mixed_quote_in_public
valid-name PUBLIC \"valid-pubid-literal\" \"invalid-system-literal'>]>
DETAIL
end

def test_no_literal_in_system
exception = assert_raise(REXML::ParseException) do
REXML::Document.new('<!DOCTYPE root [<!ENTITY valid-name SYSTEM>]>')
end
assert_equal(<<-DETAIL.chomp, exception.to_s)
Malformed entity declaration
Line: 1
Position: 45
Last 80 unconsumed characters:
valid-name SYSTEM>]>
DETAIL
end

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

# https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-PubidLiteral
Expand Down Expand Up @@ -185,6 +211,19 @@ def test_mixed_quote
valid-name PUBLIC \"invalid-pubid-literal' \"valid-system-literal\">]>
DETAIL
end

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

Expand Down Expand Up @@ -350,6 +389,32 @@ def test_mixed_quote_in_public
% valid-name PUBLIC \"valid-pubid-literal\" 'invalid-system-literal\">]>
DETAIL
end

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

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

# https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-PubidLiteral
Expand Down Expand Up @@ -394,6 +459,19 @@ def test_mixed_quote
% valid-name PUBLIC 'invalid-pubid-literal\" \"valid-system-literal\">]>
DETAIL
end

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

Expand Down

0 comments on commit 8b42c31

Please sign in to comment.