diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2017-01-28 05:43:22 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2017-01-28 05:43:22 +0000 |
commit | 3e2d20ad91657f315f73507d0d6232a1295a1f86 (patch) | |
tree | e8dbd00db2645d594e6ae3c1e80ab1f734e69d51 /test/unit/lib | |
parent | 78d1c87a9724e4ae051e32e13d84eea056ddacef (diff) | |
download | redmine-3e2d20ad91657f315f73507d0d6232a1295a1f86.tar.gz redmine-3e2d20ad91657f315f73507d0d6232a1295a1f86.zip |
add more tests (#24616)
git-svn-id: http://svn.redmine.org/redmine/trunk@16271 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/lib')
-rw-r--r-- | test/unit/lib/redmine/codeset_util_test.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/unit/lib/redmine/codeset_util_test.rb b/test/unit/lib/redmine/codeset_util_test.rb index 5c88e0f75..35ab0088d 100644 --- a/test/unit/lib/redmine/codeset_util_test.rb +++ b/test/unit/lib/redmine/codeset_util_test.rb @@ -85,4 +85,20 @@ class Redmine::CodesetUtilTest < ActiveSupport::TestCase assert_equal "test??test??", str end end + + test "#replace_invalid_utf8 should replace invalid utf8" do + s1 = "\xe3\x81\x93\xe3\x82\x93\xe3\x81\xab\xe3\x81\xa1\xE3\x81\xFF".force_encoding("UTF-8") + s2 = Redmine::CodesetUtil.replace_invalid_utf8(s1) + assert s2.valid_encoding? + assert_equal "UTF-8", s2.encoding.to_s + assert_equal "??????", s2 + end + + test "#to_utf8 should replace invalid non utf8" do + s1 = "\xa4\xb3\xa4\xf3\xa4\xcb\xa4\xc1\xa4".force_encoding("EUC-JP") + s2 = Redmine::CodesetUtil.to_utf8(s1, "EUC-JP") + assert s2.valid_encoding? + assert_equal "UTF-8", s2.encoding.to_s + assert_equal "\xe3\x81\x93\xe3\x82\x93\xe3\x81\xab\xe3\x81\xa1?".force_encoding("UTF-8"), s2 + end end |