diff options
author | Toshiaki Asai <toshi.alternative@gmail.com> | 2016-02-13 03:18:54 +0900 |
---|---|---|
committer | Toshiaki Asai <toshi.alternative@gmail.com> | 2016-02-13 03:18:54 +0900 |
commit | 1a111b7f6a493b590187a60c2cecbe59d749b315 (patch) | |
tree | 93e6f384ad813479be80bad6e1607584caa31661 /test/core | |
parent | 4bac234c28f32c53b3d1e9df260bc65c1b0978ef (diff) | |
download | mikutter-1a111b7f6a493b590187a60c2cecbe59d749b315.tar.gz |
cairo_textselectorは&<>が出現するとインデックスがずれる refs #813
Diffstat (limited to 'test/core')
-rw-r--r-- | test/core/test_cairo_textselector.rb | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/test/core/test_cairo_textselector.rb b/test/core/test_cairo_textselector.rb index 17a5f050..076b52fe 100644 --- a/test/core/test_cairo_textselector.rb +++ b/test/core/test_cairo_textselector.rb @@ -21,10 +21,31 @@ class TC_TextSelector < Test::Unit::TestCase S1 = 'this is <b>a <a>test</a></b> text'.freeze S2 = 'escape > text' S3 = 'にほんごもじれつ' + S4 = 'エンティティのテスト <<<< &&&& >>> ておくれ' + S5 = 'f<a><b>a</b>v</a>' def setup end + def test_get_aindex + mp = MockPainter.new + + s1 = S1.scan(Gdk::TextSelector::CHUNK_PATTERN) + assert_equal 8, mp.get_aindex(s1, 8) + assert_equal 10, mp.get_aindex(s1, 9) + assert_equal 9, mp.get_aindex(s1, 8, last: true) + assert_equal 10, mp.get_aindex(s1, 9, last: true) + + s5 = S5.scan(Gdk::TextSelector::CHUNK_PATTERN) + assert_equal 0, mp.get_aindex(s5, 0) + assert_equal 1, mp.get_aindex(s5, 1) + assert_equal 4, mp.get_aindex(s5, 2) + assert_equal 3, mp.get_aindex(s5, 1, last: true) + assert_equal 5, mp.get_aindex(s5, 2, last: true) + + assert_equal 9, mp.get_aindex(S2.scan(Gdk::TextSelector::CHUNK_PATTERN), 9) + end + def test_select mp = MockPainter.new assert_equal('th<span background="#000000" foreground="#ffffff">is is </span><b><span background="#000000" foreground="#ffffff">a </span><a><span background="#000000" foreground="#ffffff">te</span>st</a></b> text', @@ -34,12 +55,21 @@ class TC_TextSelector < Test::Unit::TestCase assert_equal('th<span background="#000000" foreground="#ffffff">is is <b>a <a>test</a></b> tex</span>t', mp.textselector_press(2).textselector_release(18).textselector_markup(S1)) - assert_equal('esca<span background="#000000" foreground="#ffffff">pe > t</span>ext', + assert_equal('esca<span background="#000000" foreground="#ffffff">pe > </span>text', mp.textselector_press(4).textselector_release(9).textselector_markup(S2)) assert_equal('にほ<span background="#000000" foreground="#ffffff">んごも</span>じれつ', mp.textselector_press(2).textselector_release(5).textselector_markup(S3)) + assert_equal('エンティティのテス<span background="#000000" foreground="#ffffff">ト</span> <<<< &&&& >>> ておくれ', + mp.textselector_press(9).textselector_release(10).textselector_markup(S4)) + + assert_equal('エンティティのテス<span background="#000000" foreground="#ffffff">ト </span><<<< &&&& >>> ておくれ', + mp.textselector_press(9).textselector_release(11).textselector_markup(S4)) + + assert_equal('エンティティのテス<span background="#000000" foreground="#ffffff">ト <</span><<< &&&& >>> ておくれ', + mp.textselector_press(9).textselector_release(12).textselector_markup(S4)) + end end |