diff options
Diffstat (limited to 'test/ruby/test_encoding.rb')
-rw-r--r-- | test/ruby/test_encoding.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/ruby/test_encoding.rb b/test/ruby/test_encoding.rb new file mode 100644 index 0000000000..a9bcd8eb97 --- /dev/null +++ b/test/ruby/test_encoding.rb @@ -0,0 +1,28 @@ +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 |