1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* test/rexml/test_document.rb: Add tests for parsing XML encoded

by UTF-8 with BOM.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kou 2012-10-28 14:53:07 +00:00
parent 718813ca9b
commit 5f18ce9a02
2 changed files with 25 additions and 0 deletions

View file

@ -1,3 +1,8 @@
Sun Oct 28 23:52:25 2012 Kouhei Sutou <kou@cozmixng.org>
* test/rexml/test_document.rb: Add tests for parsing XML encoded
by UTF-8 with BOM.
Sun Oct 28 23:47:09 2012 Kouhei Sutou <kou@cozmixng.org>
* lib/rexml/source.rb: Move encoding detection code to base class.

View file

@ -226,6 +226,16 @@ EOX
class BomTest < self
class HaveEncodingTest < self
def test_utf_8
xml = <<-EOX.force_encoding("ASCII-8BIT")
<?xml version="1.0" encoding="UTF-8"?>
<message>Hello world!</message>
EOX
bom = "\ufeff".force_encoding("ASCII-8BIT")
document = REXML::Document.new(bom + xml)
assert_equal("UTF-8", document.encoding)
end
def test_utf_16le
xml = <<-EOX.encode("UTF-16LE").force_encoding("ASCII-8BIT")
<?xml version="1.0" encoding="UTF-16"?>
@ -248,6 +258,16 @@ EOX
end
class NoEncodingTest < self
def test_utf_8
xml = <<-EOX.force_encoding("ASCII-8BIT")
<?xml version="1.0"?>
<message>Hello world!</message>
EOX
bom = "\ufeff".force_encoding("ASCII-8BIT")
document = REXML::Document.new(bom + xml)
assert_equal("UTF-8", document.encoding)
end
def test_utf_16le
xml = <<-EOX.encode("UTF-16LE").force_encoding("ASCII-8BIT")
<?xml version="1.0"?>