2021-06-25 05:04:27 -04:00
|
|
|
require_relative 'helper'
|
|
|
|
require "reline"
|
|
|
|
|
|
|
|
class Reline::Terminfo::Test < Reline::TestCase
|
|
|
|
def setup
|
|
|
|
Reline::Terminfo.setupterm(0, 2)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_tigetstr
|
|
|
|
assert Reline::Terminfo.tigetstr('khome')
|
2021-08-06 00:34:25 -04:00
|
|
|
rescue Reline::Terminfo::TerminfoError => e
|
2021-12-29 05:29:30 -05:00
|
|
|
omit e.message
|
2021-06-25 05:04:27 -04:00
|
|
|
end
|
|
|
|
|
2022-01-01 21:42:34 -05:00
|
|
|
def test_tigetstr_with_error
|
|
|
|
assert_raise(Reline::Terminfo::TerminfoError) { Reline::Terminfo.tigetstr('unknown') }
|
2022-01-01 21:44:45 -05:00
|
|
|
assert_raise(Reline::Terminfo::TerminfoError) { Reline::Terminfo.tigetstr(nil) }
|
2022-01-01 21:42:34 -05:00
|
|
|
end
|
|
|
|
|
2021-06-25 05:04:27 -04:00
|
|
|
def test_tiparm
|
|
|
|
assert Reline::Terminfo.tigetstr('khome').tiparm
|
2021-08-06 00:34:25 -04:00
|
|
|
rescue Reline::Terminfo::TerminfoError => e
|
2021-12-29 05:29:30 -05:00
|
|
|
omit e.message
|
2021-06-25 05:04:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_tigetstr_with_param
|
|
|
|
assert Reline::Terminfo.tigetstr('cuu').include?('%p1%d')
|
2021-08-06 00:34:25 -04:00
|
|
|
rescue Reline::Terminfo::TerminfoError => e
|
2021-12-29 05:29:30 -05:00
|
|
|
omit e.message
|
2021-06-25 05:04:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_tiparm_with_param
|
|
|
|
assert Reline::Terminfo.tigetstr('cuu').tiparm(4649).include?('4649')
|
2021-08-06 00:34:25 -04:00
|
|
|
rescue Reline::Terminfo::TerminfoError => e
|
2021-12-29 05:29:30 -05:00
|
|
|
omit e.message
|
2021-06-25 05:04:27 -04:00
|
|
|
end
|
2022-01-01 09:03:32 -05:00
|
|
|
|
|
|
|
def test_tigetflag
|
|
|
|
assert_instance_of Integer, Reline::Terminfo.tigetflag('xenl')
|
|
|
|
rescue Reline::Terminfo::TerminfoError => e
|
|
|
|
omit e.message
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_tigetflag_with_error
|
|
|
|
assert_raise(Reline::Terminfo::TerminfoError) { Reline::Terminfo.tigetflag('cuu') }
|
|
|
|
assert_raise(Reline::Terminfo::TerminfoError) { Reline::Terminfo.tigetflag('unknown') }
|
2022-01-01 21:44:45 -05:00
|
|
|
assert_raise(Reline::Terminfo::TerminfoError) { Reline::Terminfo.tigetflag(nil) }
|
2022-01-01 09:03:32 -05:00
|
|
|
end
|
2022-01-01 20:17:33 -05:00
|
|
|
|
|
|
|
def test_tigetnum
|
|
|
|
assert_instance_of Integer, Reline::Terminfo.tigetnum('colors')
|
|
|
|
rescue Reline::Terminfo::TerminfoError => e
|
|
|
|
omit e.message
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_tigetnum_with_error
|
|
|
|
assert_raise(Reline::Terminfo::TerminfoError) { Reline::Terminfo.tigetnum('cuu') }
|
|
|
|
assert_raise(Reline::Terminfo::TerminfoError) { Reline::Terminfo.tigetnum('unknown') }
|
2022-01-01 21:44:45 -05:00
|
|
|
assert_raise(Reline::Terminfo::TerminfoError) { Reline::Terminfo.tigetnum(nil) }
|
2022-01-01 20:17:33 -05:00
|
|
|
end
|
2021-06-25 05:04:27 -04:00
|
|
|
end if Reline::Terminfo.enabled?
|