summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-28 12:19:58 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-28 12:19:58 +0000
commit100b3be9ae7f6ad0af53dd87d0e9706df6e813c3 (patch)
treeac52fd9a92b25b5e64f331d1af2974efedf7ded5 /test
parentf774c96beb1fd61720b335b1b7b54cf9422a6f2d (diff)
downloadruby-100b3be9ae7f6ad0af53dd87d0e9706df6e813c3.tar.gz
* test/rexml/test_document.rb: Add tests for parsing XML encoded
by UTF-16 with BOM. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/rexml/test_document.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/rexml/test_document.rb b/test/rexml/test_document.rb
index 72d0ff696f..02e4a69754 100644
--- a/test/rexml/test_document.rb
+++ b/test/rexml/test_document.rb
@@ -223,4 +223,26 @@ EOX
end
end
end
+
+ class BomTest < self
+ def test_utf_16le
+ xml = <<-EOX.encode("UTF-16LE").force_encoding("ASCII-8BIT")
+<?xml version="1.0" encoding="UTF-16"?>
+<message>Hello world!</message>
+EOX
+ bom = "\ufeff".encode("UTF-16LE").force_encoding("ASCII-8BIT")
+ document = REXML::Document.new(bom + xml)
+ assert_equal("UTF-16", document.encoding)
+ end
+
+ def test_utf_16be
+ xml = <<-EOX.encode("UTF-16BE").force_encoding("ASCII-8BIT")
+<?xml version="1.0" encoding="UTF-16"?>
+<message>Hello world!</message>
+EOX
+ bom = "\ufeff".encode("UTF-16BE").force_encoding("ASCII-8BIT")
+ document = REXML::Document.new(bom + xml)
+ assert_equal("UTF-16", document.encoding)
+ end
+ end
end