summaryrefslogtreecommitdiff
path: root/test/psych/test_parser.rb
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-19 03:12:03 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-19 03:12:03 +0000
commit15335f8aaa8282fd951935135aa04b3d938a267c (patch)
treedd5eabbc54d17c2454dddb00136bb684ee85cd33 /test/psych/test_parser.rb
parenta8f8b617c0c609557c80f85de59a4472cc5d45d5 (diff)
* ext/psych/emitter.c: using xmalloc and xfree for memory allocation
* ext/psych/lib/psych/nodes/stream.rb: encoding should be read / write * ext/psych/parser.c: supporting UTF-16 and UTF-16 + BOM * test/psych/test_parser.rb: testing UTF-16 and UTF-16 + BOM git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/psych/test_parser.rb')
-rw-r--r--test/psych/test_parser.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/psych/test_parser.rb b/test/psych/test_parser.rb
index 9ef2a41e1d..8c4483309b 100644
--- a/test/psych/test_parser.rb
+++ b/test/psych/test_parser.rb
@@ -1,3 +1,5 @@
+# coding: utf-8
+
require_relative 'helper'
module Psych
@@ -24,6 +26,23 @@ module Psych
@parser = Psych::Parser.new EventCatcher.new
end
+ def test_bom
+ tadpole = 'おたまじゃくし'
+
+ # BOM + text
+ yml = "\uFEFF#{tadpole}".encode('UTF-16LE')
+ @parser.parse yml
+ assert_equal tadpole, @parser.handler.calls[2][1].first
+ end
+
+ def test_external_encoding
+ tadpole = 'おたまじゃくし'
+
+ @parser.external_encoding = Psych::Parser::UTF16LE
+ @parser.parse tadpole.encode 'UTF-16LE'
+ assert_equal tadpole, @parser.handler.calls[2][1].first
+ end
+
def test_bogus_io
o = Object.new
def o.read len; self end