diff options
author | Go MAEDA <maeda@farend.jp> | 2019-03-19 15:43:55 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2019-03-19 15:43:55 +0000 |
commit | 26509e7f4c6dae94baf291b95d46eb6ec8ebca0b (patch) | |
tree | eca8843de4ca00c229612e8f4f323a5474444a29 /test/unit/lib/redmine/unified_diff_test.rb | |
parent | 7d2f10ccac0e51a8eb337ed388ab8182df4c25e1 (diff) | |
download | redmine-26509e7f4c6dae94baf291b95d46eb6ec8ebca0b.tar.gz redmine-26509e7f4c6dae94baf291b95d46eb6ec8ebca0b.zip |
Decode hexadecimal-encoded literals in order to be frozen string literals friendly (#31004).
Patch by Yuichi HARADA.
git-svn-id: http://svn.redmine.org/redmine/trunk@17991 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/lib/redmine/unified_diff_test.rb')
-rw-r--r-- | test/unit/lib/redmine/unified_diff_test.rb | 37 |
1 files changed, 12 insertions, 25 deletions
diff --git a/test/unit/lib/redmine/unified_diff_test.rb b/test/unit/lib/redmine/unified_diff_test.rb index efd7780d9..ff5174e03 100644 --- a/test/unit/lib/redmine/unified_diff_test.rb +++ b/test/unit/lib/redmine/unified_diff_test.rb @@ -274,23 +274,20 @@ DIFF end def test_utf8_ja - ja = " text_tip_issue_end_day: " - ja += "\xe3\x81\x93\xe3\x81\xae\xe6\x97\xa5\xe3\x81\xab\xe7\xb5\x82\xe4\xba\x86\xe3\x81\x99\xe3\x82\x8b<span>\xe3\x82\xbf\xe3\x82\xb9\xe3\x82\xaf</span>".force_encoding('UTF-8') with_settings :repositories_encodings => '' do diff = Redmine::UnifiedDiff.new(read_diff_fixture('issue-12641-ja.diff'), :type => 'inline') assert_equal 1, diff.size assert_equal 12, diff.first.size - assert_equal ja, diff.first[4].html_line_left + assert_equal ' text_tip_issue_end_day: この日に終了する<span>タスク</span>', diff.first[4].html_line_left end end def test_utf8_ru - ru = " other: "\xd0\xbe\xd0\xba\xd0\xbe\xd0\xbb\xd0\xbe %{count} \xd1\x87\xd0\xb0\xd1\x81<span>\xd0\xb0</span>"".force_encoding('UTF-8') with_settings :repositories_encodings => '' do diff = Redmine::UnifiedDiff.new(read_diff_fixture('issue-12641-ru.diff'), :type => 'inline') assert_equal 1, diff.size assert_equal 8, diff.first.size - assert_equal ru, diff.first[3].html_line_left + assert_equal ' other: "около %{count} час<span>а</span>"', diff.first[3].html_line_left end end @@ -329,70 +326,60 @@ DIFF end def test_offset_range_japanese_1 - ja1 = "\xe6\x97\xa5\xe6\x9c\xac<span></span>".force_encoding('UTF-8') - ja2 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xaa\x9e</span>".force_encoding('UTF-8') with_settings :repositories_encodings => '' do diff = Redmine::UnifiedDiff.new( read_diff_fixture('issue-13644-1.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 + assert_equal '日本<span></span>', diff.first[1].html_line_left + assert_equal '日本<span>語</span>', diff.first[1].html_line_right end end def test_offset_range_japanese_2 - ja1 = "<span></span>\xe6\x97\xa5\xe6\x9c\xac".force_encoding('UTF-8') - ja2 = "<span>\xe3\x81\xab\xe3\x81\xa3\xe3\x81\xbd\xe3\x82\x93</span>\xe6\x97\xa5\xe6\x9c\xac".force_encoding('UTF-8') with_settings :repositories_encodings => '' do diff = Redmine::UnifiedDiff.new( read_diff_fixture('issue-13644-2.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 + assert_equal '<span></span>日本', diff.first[1].html_line_left + assert_equal '<span>にっぽん</span>日本', diff.first[1].html_line_right 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>".force_encoding('UTF-8') - ja2 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe5\xa8\x98</span>".force_encoding('UTF-8') 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 + assert_equal '日本<span>記</span>', diff.first[1].html_line_left + assert_equal '日本<span>娘</span>', 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>".force_encoding('UTF-8') - ja2 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xaa\x98</span>".force_encoding('UTF-8') 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 + assert_equal '日本<span>記</span>', diff.first[1].html_line_left + assert_equal '日本<span>誘</span>', 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".force_encoding('UTF-8') - ja2 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xaa\x98</span>ok".force_encoding('UTF-8') 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 + assert_equal '日本<span>記</span>ok', diff.first[1].html_line_left + assert_equal '日本<span>誘</span>ok', diff.first[1].html_line_right end end |