summaryrefslogtreecommitdiff
path: root/test/rexml
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-28 14:53:07 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-28 14:53:07 +0000
commit5f18ce9a0277772e581c0c74a0026f26a3092e6b (patch)
tree4c696809fd3bfc387e331d4fbb4e3c53cdf86546 /test/rexml
parent718813ca9b2228274b32a9119023074be116fe9b (diff)
* 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
Diffstat (limited to 'test/rexml')
-rw-r--r--test/rexml/test_document.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/rexml/test_document.rb b/test/rexml/test_document.rb
index 4c5d7d1..3b6d712 100644
--- a/test/rexml/test_document.rb
+++ b/test/rexml/test_document.rb
@@ -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"?>