From 323d7174f54d8b3141d0f567f0b985f18bda84e8 Mon Sep 17 00:00:00 2001 From: duerst Date: Thu, 21 Feb 2008 08:42:10 +0000 Subject: Thu Feb 21 17:15:15 2008 Martin Duerst * transcode.c: Added basic support for passing options to String#encode via a hash. Currently only one option, with one value, is supported: invalid: :ignore (dropping invalid byte sequences instead of producing an error). Option naming is not yet stable! * test/ruby/test_transcode.rb: Added a single test for invalid: :ignore option. Not more tests because most data does not yet distinguish between INVALID and UNKNOWN. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@15565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_transcode.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'test/ruby/test_transcode.rb') diff --git a/test/ruby/test_transcode.rb b/test/ruby/test_transcode.rb index 957d852c1..9edf30882 100644 --- a/test/ruby/test_transcode.rb +++ b/test/ruby/test_transcode.rb @@ -19,8 +19,6 @@ class TestTranscode < Test::Unit::TestCase end def test_errors - # we don't have semantics for conversion without attribute yet - # maybe 'convert to UTF-8' would be nice :-) assert_raise(ArgumentError) { 'abc'.encode } assert_raise(ArgumentError) { 'abc'.encode! } assert_raise(ArgumentError) { 'abc'.encode('foo', 'bar') } @@ -241,4 +239,9 @@ class TestTranscode < Test::Unit::TestCase check_utf_32_both_ways("\u{8FF00}", "\x00\x08\xFF\x00") check_utf_32_both_ways("\u{F00FF}", "\x00\x0F\x00\xFF") end + + def test_invalid_ignore + # arguments only + 'abc'.encode('utf-8', invalid: :ignore) + end end -- cgit