mirror of
https://github.com/ruby/ruby.git
synced 2025-09-20 19:14:00 +02:00
* 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
This commit is contained in:
parent
a8f8b617c0
commit
15335f8aaa
4 changed files with 75 additions and 34 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue