-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch will add missing REXML::Text.check tests. This is the tests for the part that is checked using a regular expression. https://github.com/ruby/rexml/blob/b2ec329dc1dc7635b224a6d61687c24b1e1db6fd/lib/rexml/text.rb#L155-L172
- Loading branch information
1 parent
b2ec329
commit 7768883
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# frozen_string_literal: false | ||
|
||
module REXMLTests | ||
class TextCheckTester < Test::Unit::TestCase | ||
include REXML | ||
|
||
def test_valid_pattern | ||
chars = ['&A;', '&:;', '&_;', '&:A;', '&AA.bb-00;'] | ||
chars.each do |token| | ||
text = Text.new(token, false, nil, true) | ||
assert_equal(token, text.to_s) | ||
end | ||
|
||
character_entities = ['&', '<', '>', '"', ''', ' ', 'Ψ'] | ||
character_entities.each do |token| | ||
text = Text.new(token, false, nil, true) | ||
assert_equal(token, text.to_s) | ||
end | ||
|
||
numeric_entities = [' ', '"', '♦', '
', '¢', '', ''] | ||
numeric_entities.each do |token| | ||
text = Text.new(token, false, nil, true) | ||
assert_equal(token, text.to_s) | ||
end | ||
|
||
unicode_entities = ['	', '
', '
', '„', 'Ÿ', '', '', ''] | ||
unicode_entities.each do |token| | ||
text = Text.new(token, false, nil, true) | ||
assert_equal(token, text.to_s) | ||
end | ||
|
||
unicodes = ["&\u00C0;", "&\uFDF0;", "&\u{10000};", "&\u00D6\u0300\u0300;"] | ||
unicodes.each do |unicode| | ||
text = Text.new(unicode, false, nil, true) | ||
assert_equal(unicode, text.to_s) | ||
end | ||
end | ||
|
||
def test_invalid_pattern | ||
chars = ['<', '<;', '&', '&42;','&#A;', '', '', '', '�', '', '�', '�'] | ||
chars.each do |token| | ||
assert_raise(RuntimeError) { Text.new(token, false, nil, true) } | ||
end | ||
end | ||
end | ||
end |