aboutsummaryrefslogtreecommitdiffstats
path: root/test/rexml
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-03 05:42:40 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-03 05:42:40 +0000
commitac9a8ac62416cfc7c6faf059651b7945cb5e3bf6 (patch)
tree3418221eaae6f263b7698ba87aeeee08aae51540 /test/rexml
parent15a743b3ff393092f19fb8e57bd79675dd208b02 (diff)
downloadruby-ac9a8ac62416cfc7c6faf059651b7945cb5e3bf6.tar.gz
* lib/rexml/output.rb (REXML::Output): Don't output BOM in middle
of the output string. * test/rexml/test_document.rb: Add a test for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rexml')
-rw-r--r--test/rexml/test_document.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/rexml/test_document.rb b/test/rexml/test_document.rb
index 0e154db20f..3ef584c290 100644
--- a/test/rexml/test_document.rb
+++ b/test/rexml/test_document.rb
@@ -296,5 +296,24 @@ EOX
assert_equal("UTF-16", document.encoding)
end
end
+
+ class WriteTest < self
+ def test_utf_16
+ xml = <<-EOX.encode("UTF-16LE").force_encoding("ASCII-8BIT")
+<?xml version="1.0"?>
+<message>Hello world!</message>
+EOX
+ bom = "\ufeff".encode("UTF-16LE").force_encoding("ASCII-8BIT")
+ document = REXML::Document.new(bom + xml)
+
+ actual_xml = ""
+ document.write(actual_xml)
+ expected_xml = <<-EOX.encode("UTF-16BE")
+\ufeff<?xml version='1.0' encoding='UTF-16'?>
+<message>Hello world!</message>
+EOX
+ assert_equal(expected_xml, actual_xml)
+ end
+ end
end
end