Mercurial > hg > soundsoftware-site
diff test/unit/lib/redmine/export/pdf_test.rb @ 507:0c939c159af4 redmine-1.2
Update to Redmine 1.2.1 on 1.2-stable branch (Redmine SVN rev 6270)
author | Chris Cannam |
---|---|
date | Thu, 14 Jul 2011 10:32:19 +0100 |
parents | cbce1fd3b1b7 |
children | cbb26bc654de |
line wrap: on
line diff
--- a/test/unit/lib/redmine/export/pdf_test.rb Mon Jun 06 14:24:13 2011 +0100 +++ b/test/unit/lib/redmine/export/pdf_test.rb Thu Jul 14 10:32:19 2011 +0100 @@ -24,8 +24,12 @@ def test_fix_text_encoding_nil set_language_if_valid 'ja' assert_equal 'CP932', l(:general_pdf_encoding) - if RUBY_VERSION < '1.9' - ic = Iconv.new(l(:general_pdf_encoding), 'UTF-8') + if RUBY_VERSION < '1.9' + if RUBY_PLATFORM == 'java' + ic = Iconv.new("SJIS", 'UTF-8') + else + ic = Iconv.new(l(:general_pdf_encoding), 'UTF-8') + end end assert_equal '', Redmine::Export::PDF::RDMPdfEncoding::rdm_pdf_iconv(ic, nil) end @@ -34,7 +38,11 @@ set_language_if_valid 'ja' assert_equal 'CP932', l(:general_pdf_encoding) if RUBY_VERSION < '1.9' - ic = Iconv.new(l(:general_pdf_encoding), 'UTF-8') + if RUBY_PLATFORM == 'java' + ic = Iconv.new("SJIS", 'UTF-8') + else + ic = Iconv.new(l(:general_pdf_encoding), 'UTF-8') + end end utf8_txt_1 = "\xe7\x8b\x80\xe6\x85\x8b" utf8_txt_2 = "\xe7\x8b\x80\xe6\x85\x8b\xe7\x8b\x80" @@ -49,6 +57,13 @@ assert_equal "ASCII-8BIT", txt_1.encoding.to_s assert_equal "ASCII-8BIT", txt_2.encoding.to_s assert_equal "ASCII-8BIT", txt_3.encoding.to_s + elsif RUBY_PLATFORM == 'java' + assert_equal "??", + Redmine::Export::PDF::RDMPdfEncoding::rdm_pdf_iconv(ic, utf8_txt_1) + assert_equal "???", + Redmine::Export::PDF::RDMPdfEncoding::rdm_pdf_iconv(ic, utf8_txt_2) + assert_equal "????", + Redmine::Export::PDF::RDMPdfEncoding::rdm_pdf_iconv(ic, utf8_txt_3) else assert_equal "???\x91\xd4", Redmine::Export::PDF::RDMPdfEncoding::rdm_pdf_iconv(ic, utf8_txt_1) @@ -87,7 +102,11 @@ str1.force_encoding("UTF-8") if str1.respond_to?(:force_encoding) str2.force_encoding("ASCII-8BIT") if str2.respond_to?(:force_encoding) if RUBY_VERSION < '1.9' - ic = Iconv.new(l(:general_pdf_encoding), 'UTF-8') + if RUBY_PLATFORM == 'java' + ic = Iconv.new("SJIS", 'UTF-8') + else + ic = Iconv.new(l(:general_pdf_encoding), 'UTF-8') + end end txt_1 = Redmine::Export::PDF::RDMPdfEncoding::rdm_pdf_iconv(ic, str1) txt_2 = Redmine::Export::PDF::RDMPdfEncoding::rdm_pdf_iconv(ic, str2)