1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/ruby/test_encoding.rb
nobu b314d3e999 * encoding.c (rb_obj_encoding): rdoc update. a patch from David
Flanagan <david AT davidflanagan.com>.  [ruby-core:12664]

* encoding.c (enc_dump, enc_load): marshaling feature.  a patch from
  David Flanagan.  [ruby-core:12665]

* encoding.c (Init_Encoding): undefine allocator of Encoding.
  [ruby-core:12665], [ruby-core:12666]

* test/ruby/test_encoding.rb: tests for Encoding from David Flanagan
  [ruby-core:12665]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13697 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-14 08:31:51 +00:00

28 lines
803 B
Ruby

require 'test/unit'
class TestEncoding < Test::Unit::TestCase
# Test basic encoding methods: list, find, name
def test_encoding
encodings = Encoding.list
assert_equal(encodings.empty?, false)
encodings.each do |e|
assert_equal(e, Encoding.find(e.name))
assert_equal(e, Encoding.find(e.name.upcase))
assert_equal(e, Encoding.find(e.name.capitalize))
assert_equal(e, Encoding.find(e.name.downcase))
end
end
# Test that Encoding objects can't be copied
# And that they can be compared by object_id
def test_singleton
encodings = Encoding.list
encodings.each do |e|
assert_raise(TypeError) { e.dup }
assert_raise(TypeError) { e.clone }
assert_equal(e.object_id, Marshal.load(Marshal.dump(e)).object_id)
end
end
end