aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-22 06:52:54 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-22 06:52:54 +0000
commit81fc1cf2017840d0786cf997b4d2a80f80060001 (patch)
treeed95702464f90d637072a7912e6ad681262b3d2d /test
parenta532dcafe6f523b79024cb1ee7cff31cc1127ae3 (diff)
downloadruby-81fc1cf2017840d0786cf997b4d2a80f80060001.tar.gz
* encoding.c (rb_enc_mbclen): return minlen instead of 1 when
a character is not found properly. * string.c (rb_enc_strlen): round up string length with fixed multibyte encoding such as UTF-32. (rb_enc_strlen_cr): ditto. (rb_str_substr): fix substring with fixed multibyte encoding. (rb_str_justify): check number of characters. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_utf32.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/ruby/test_utf32.rb b/test/ruby/test_utf32.rb
new file mode 100644
index 0000000000..f81524f29e
--- /dev/null
+++ b/test/ruby/test_utf32.rb
@@ -0,0 +1,27 @@
+require 'test/unit'
+
+class TestUTF32 < Test::Unit::TestCase
+ def encdump(str)
+ d = str.dump
+ if /\.force_encoding\("[A-Za-z0-9.:_+-]*"\)\z/ =~ d
+ d
+ else
+ "#{d}.force_encoding(#{str.encoding.name.dump})"
+ end
+ end
+
+ def assert_str_equal(expected, actual, message=nil)
+ full_message = build_message(message, <<EOT)
+#{encdump expected} expected but not equal to
+#{encdump actual}.
+EOT
+ assert_block(full_message) { expected == actual }
+ end
+
+ def test_substr
+ assert_str_equal(
+ "abcdefgh".force_encoding("utf-32be"),
+ "abcdefgh".force_encoding("utf-32be")[0,3])
+ end
+end
+