summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2013-07-28 11:00:02 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2013-07-28 11:00:02 +0000
commit670d2b6e2bebdc84aaa4a525d164bf50f8f2eb4b (patch)
tree10ce59f9fc795f47de0081193df12ec68154788d /test/unit
parent0ac3afebc62b37e70b3ab69a4d8d4602671dfb46 (diff)
downloadredmine-670d2b6e2bebdc84aaa4a525d164bf50f8f2eb4b.tar.gz
redmine-670d2b6e2bebdc84aaa4a525d164bf50f8f2eb4b.zip
fix diff of CJK(Chinese/Japanese/Korean) is broken on Ruby 1.8 (#14562)
Contributed by Jun NAITOH. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12046 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/lib/redmine/unified_diff_test.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/unit/lib/redmine/unified_diff_test.rb b/test/unit/lib/redmine/unified_diff_test.rb
index 7e1ccbdd9..4dd5357db 100644
--- a/test/unit/lib/redmine/unified_diff_test.rb
+++ b/test/unit/lib/redmine/unified_diff_test.rb
@@ -308,6 +308,54 @@ DIFF
end
end
+ def test_offset_range_japanese_3
+ # UTF-8 The 1st byte differs.
+ ja1 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xa8\x98</span>"
+ ja1.force_encoding('UTF-8') if ja1.respond_to?(:force_encoding)
+ ja2 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe5\xa8\x98</span>"
+ ja2.force_encoding('UTF-8') if ja2.respond_to?(:force_encoding)
+ with_settings :repositories_encodings => '' do
+ diff = Redmine::UnifiedDiff.new(
+ read_diff_fixture('issue-13644-3.diff'), :type => 'sbs')
+ assert_equal 1, diff.size
+ assert_equal 3, diff.first.size
+ assert_equal ja1, diff.first[1].html_line_left
+ assert_equal ja2, diff.first[1].html_line_right
+ end
+ end
+
+ def test_offset_range_japanese_4
+ # UTF-8 The 2nd byte differs.
+ ja1 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xa8\x98</span>"
+ ja1.force_encoding('UTF-8') if ja1.respond_to?(:force_encoding)
+ ja2 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xaa\x98</span>"
+ ja2.force_encoding('UTF-8') if ja2.respond_to?(:force_encoding)
+ with_settings :repositories_encodings => '' do
+ diff = Redmine::UnifiedDiff.new(
+ read_diff_fixture('issue-13644-4.diff'), :type => 'sbs')
+ assert_equal 1, diff.size
+ assert_equal 3, diff.first.size
+ assert_equal ja1, diff.first[1].html_line_left
+ assert_equal ja2, diff.first[1].html_line_right
+ end
+ end
+
+ def test_offset_range_japanese_5
+ # UTF-8 The 2nd byte differs.
+ ja1 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xa8\x98</span>ok"
+ ja1.force_encoding('UTF-8') if ja1.respond_to?(:force_encoding)
+ ja2 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xaa\x98</span>ok"
+ ja2.force_encoding('UTF-8') if ja2.respond_to?(:force_encoding)
+ with_settings :repositories_encodings => '' do
+ diff = Redmine::UnifiedDiff.new(
+ read_diff_fixture('issue-13644-5.diff'), :type => 'sbs')
+ assert_equal 1, diff.size
+ assert_equal 3, diff.first.size
+ assert_equal ja1, diff.first[1].html_line_left
+ assert_equal ja2, diff.first[1].html_line_right
+ end
+ end
+
private
def read_diff_fixture(filename)