summaryrefslogtreecommitdiffstats
path: root/test/unit/lib
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/lib')
-rw-r--r--test/unit/lib/redmine/codeset_util_test.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/unit/lib/redmine/codeset_util_test.rb b/test/unit/lib/redmine/codeset_util_test.rb
index aaf664047..56094ecfa 100644
--- a/test/unit/lib/redmine/codeset_util_test.rb
+++ b/test/unit/lib/redmine/codeset_util_test.rb
@@ -101,4 +101,21 @@ class Redmine::CodesetUtilTest < ActiveSupport::TestCase
assert_equal "UTF-8", s2.encoding.to_s
assert_equal 'こんにち?', s2
end
+
+ def test_guess_encoding_should_return_guessed_encoding
+ str = '日本語'.encode('Windows-31J').b
+ with_settings :repositories_encodings => 'UTF-8,Windows-31J' do
+ assert_equal 'Windows-31J', Redmine::CodesetUtil.guess_encoding(str)
+ end
+ with_settings :repositories_encodings => 'UTF-8,csWindows31J' do
+ assert_equal 'csWindows31J', Redmine::CodesetUtil.guess_encoding(str)
+ end
+ end
+
+ def guess_encoding_should_return_nil_if_cannot_guess_encoding
+ str = '日本語'.encode('Windows-31J').b
+ with_settings :repositories_encodings => 'UTF-8,EUC-JP' do
+ assert_nil Redmine::CodesetUtil.guess_encoding(str)
+ end
+ end
end