summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authortomoya ishida <tomoyapenguin@gmail.com>2023-03-26 00:01:30 +0900
committergit <svn-admin@ruby-lang.org>2023-03-25 15:01:35 +0000
commit60ca800d4fc410ea9d49ef24dfb80577d4183f15 (patch)
tree7e68200a425aa23565fdc1478ccd51eeed887a5a /test
parent9bc2dbd33cd25281fe14d01bbe5b460176db1010 (diff)
[ruby/reline] Fix split_by_width to retain color sequences
(https://github.com/ruby/reline/pull/490) * Fix split_by_width to retain color sequences * Add OSC escape sequence testcase of Reline::Unicode.split_by_width
Diffstat (limited to 'test')
-rw-r--r--test/reline/test_unicode.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/reline/test_unicode.rb b/test/reline/test_unicode.rb
index 1233e034e8..0a66fe64c0 100644
--- a/test/reline/test_unicode.rb
+++ b/test/reline/test_unicode.rb
@@ -18,6 +18,15 @@ class Reline::Unicode::Test < Reline::TestCase
assert_equal 2, Reline::Unicode.calculate_width('√', true)
end
+ def test_split_by_width
+ assert_equal [['abc', nil, 'de'], 2], Reline::Unicode.split_by_width('abcde', 3)
+ assert_equal [['abc', nil, 'def', nil, ''], 3], Reline::Unicode.split_by_width('abcdef', 3)
+ assert_equal [['ab', nil, 'あd', nil, 'ef'], 3], Reline::Unicode.split_by_width('abあdef', 3)
+ assert_equal [["ab\1zero\2c", nil, 'def', nil, ''], 3], Reline::Unicode.split_by_width("ab\1zero\2cdef", 3)
+ assert_equal [["\e[31mabc", nil, "\e[31md\e[42mef", nil, "\e[31m\e[42mg"], 3], Reline::Unicode.split_by_width("\e[31mabcd\e[42mefg", 3)
+ assert_equal [["ab\e]0;1\ac", nil, "\e]0;1\ad"], 2], Reline::Unicode.split_by_width("ab\e]0;1\acd", 3)
+ end
+
def test_take_range
assert_equal 'cdef', Reline::Unicode.take_range('abcdefghi', 2, 4)
assert_equal 'いう', Reline::Unicode.take_range('あいうえお', 2, 4)