From 15335f8aaa8282fd951935135aa04b3d938a267c Mon Sep 17 00:00:00 2001 From: tenderlove Date: Wed, 19 May 2010 03:12:03 +0000 Subject: * 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 --- test/psych/test_parser.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/psych/test_parser.rb') 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 -- cgit v1.2.3