Skip to content

Commit

Permalink
Add test for take_range options
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng committed Sep 28, 2022
1 parent 243b43b commit 1bd87c9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions test/reline/test_unicode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ def test_ambiguous_width
end

def test_take_range
assert_equal 'cdef', Reline::Unicode.take_range('abcdefghi', 2, 4)
assert_equal 'いう', Reline::Unicode.take_range('あいうえお', 2, 4)
assert_equal ['cdef', 2, 4], Reline::Unicode.take_range('abcdefghi', 2, 4)
assert_equal ['いう', 2, 4], Reline::Unicode.take_range('あいうえお', 2, 4)
assert_equal ['う', 4, 2], Reline::Unicode.take_range('あいうえお', 3, 4)
assert_equal [' う ', 3, 4], Reline::Unicode.take_range('あいうえお', 3, 4, padding: true)
assert_equal ['いう', 2, 4], Reline::Unicode.take_range('あいうえお', 3, 4, cover_begin: true)
assert_equal ['うえ', 4, 4], Reline::Unicode.take_range('あいうえお', 3, 4, cover_end: true)
assert_equal [' うえお ', 3, 10], Reline::Unicode.take_range('あいうえお', 3, 10, padding: true)
assert_equal ["\e[31mc\1ABC\2d\e[0mef", 2, 4], Reline::Unicode.take_range("\e[31mabc\1ABC\2d\e[0mefghi", 2, 4)
end
end

0 comments on commit 1bd87c9

Please sign in to comment.