1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-01-17 21:02:54 +00:00

add more tests (#24616)

git-svn-id: http://svn.redmine.org/redmine/trunk@16271 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2017-01-28 05:43:22 +00:00
parent 78d1c87a97
commit 3e2d20ad91

View File

@ -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