mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Check the result of tigetstr
This commit is contained in:
parent
9bfb8ea671
commit
3e7fb4b91d
2 changed files with 14 additions and 1 deletions
|
@ -98,7 +98,12 @@ module Reline::Terminfo
|
|||
end
|
||||
|
||||
def self.tigetstr(capname)
|
||||
StringWithTiparm.new(@tigetstr.(capname).to_s)
|
||||
capability = @tigetstr.(capname)
|
||||
case capability.to_i
|
||||
when 0, -1
|
||||
raise TerminfoError, "can't find capability: #{capname}"
|
||||
end
|
||||
StringWithTiparm.new(capability.to_s)
|
||||
end
|
||||
|
||||
def self.tiparm(str, *args)
|
||||
|
|
|
@ -10,17 +10,25 @@ class Reline::Terminfo::Test < Reline::TestCase
|
|||
|
||||
def test_tigetstr
|
||||
assert Reline::Terminfo.tigetstr('khome')
|
||||
rescue Reline::Terminfo::TerminfoError => e
|
||||
skip e.message
|
||||
end
|
||||
|
||||
def test_tiparm
|
||||
assert Reline::Terminfo.tigetstr('khome').tiparm
|
||||
rescue Reline::Terminfo::TerminfoError => e
|
||||
skip e.message
|
||||
end
|
||||
|
||||
def test_tigetstr_with_param
|
||||
assert Reline::Terminfo.tigetstr('cuu').include?('%p1%d')
|
||||
rescue Reline::Terminfo::TerminfoError => e
|
||||
skip e.message
|
||||
end
|
||||
|
||||
def test_tiparm_with_param
|
||||
assert Reline::Terminfo.tigetstr('cuu').tiparm(4649).include?('4649')
|
||||
rescue Reline::Terminfo::TerminfoError => e
|
||||
skip e.message
|
||||
end
|
||||
end if Reline::Terminfo.enabled?
|
||||
|
|
Loading…
Reference in a new issue