2020-11-11 23:42:29 -05:00
|
|
|
require_relative 'helper'
|
|
|
|
require "reline/unicode"
|
|
|
|
|
|
|
|
class Reline::Unicode::Test < Reline::TestCase
|
|
|
|
def setup
|
|
|
|
Reline.send(:test_mode)
|
|
|
|
end
|
|
|
|
|
2021-06-21 09:06:33 -04:00
|
|
|
def teardown
|
|
|
|
Reline.test_reset
|
|
|
|
end
|
|
|
|
|
2020-11-11 23:42:29 -05:00
|
|
|
def test_get_mbchar_width
|
|
|
|
assert_equal Reline.ambiguous_width, Reline::Unicode.get_mbchar_width('é')
|
|
|
|
end
|
2020-12-21 10:59:48 -05:00
|
|
|
|
|
|
|
def test_ambiguous_width
|
|
|
|
assert_equal 2, Reline::Unicode.calculate_width('√', true)
|
|
|
|
end
|
2021-09-05 17:50:34 -04:00
|
|
|
|
|
|
|
def test_take_range
|
|
|
|
assert_equal 'cdef', Reline::Unicode.take_range('abcdefghi', 2, 4)
|
|
|
|
assert_equal 'いう', Reline::Unicode.take_range('あいうえお', 2, 4)
|
|
|
|
end
|
2020-11-11 23:42:29 -05:00
|
|
|
end
|