1
0
Fork 0
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:
Nobuyoshi Nakada 2021-08-06 13:34:25 +09:00
parent 9bfb8ea671
commit 3e7fb4b91d
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
2 changed files with 14 additions and 1 deletions

View file

@ -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)

View file

@ -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?