From 5f18ce9a0277772e581c0c74a0026f26a3092e6b Mon Sep 17 00:00:00 2001 From: kou Date: Sun, 28 Oct 2012 14:53:07 +0000 Subject: * 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 --- test/rexml/test_document.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/rexml') diff --git a/test/rexml/test_document.rb b/test/rexml/test_document.rb index 4c5d7d1dd8..3b6d7121fe 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") + +Hello world! +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") @@ -248,6 +258,16 @@ EOX end class NoEncodingTest < self + def test_utf_8 + xml = <<-EOX.force_encoding("ASCII-8BIT") + +Hello world! +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") -- cgit v1.2.3