mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-12-23 03:19:01 +00:00
Add regression test case for #91
This commit is contained in:
parent
75b44aac13
commit
2924fd3e23
5
fzf
5
fzf
@ -366,7 +366,8 @@ class FZF
|
|||||||
end if str
|
end if str
|
||||||
end
|
end
|
||||||
def addstr_safe str
|
def addstr_safe str
|
||||||
C.addstr str.gsub("\0", '')
|
str = str.gsub("\0", '') rescue str
|
||||||
|
C.addstr str
|
||||||
end
|
end
|
||||||
|
|
||||||
def print_input
|
def print_input
|
||||||
@ -1105,7 +1106,7 @@ class FZF
|
|||||||
begin
|
begin
|
||||||
unless @delim
|
unless @delim
|
||||||
# AWK default
|
# AWK default
|
||||||
prefix_length = (str.index(/\S/) rescue 0)|| 0
|
prefix_length = (str.index(/\S/) || 0) rescue 0
|
||||||
tokens = str.scan(/\S+\s*/) rescue []
|
tokens = str.scan(/\S+\s*/) rescue []
|
||||||
else
|
else
|
||||||
prefix_length = 0
|
prefix_length = 0
|
||||||
|
@ -5,6 +5,7 @@ require 'curses'
|
|||||||
require 'timeout'
|
require 'timeout'
|
||||||
require 'stringio'
|
require 'stringio'
|
||||||
require 'minitest/autorun'
|
require 'minitest/autorun'
|
||||||
|
require 'tempfile'
|
||||||
$LOAD_PATH.unshift File.expand_path('../..', __FILE__)
|
$LOAD_PATH.unshift File.expand_path('../..', __FILE__)
|
||||||
ENV['FZF_EXECUTABLE'] = '0'
|
ENV['FZF_EXECUTABLE'] = '0'
|
||||||
load 'fzf'
|
load 'fzf'
|
||||||
@ -614,7 +615,7 @@ class TestFZF < MiniTest::Unit::TestCase
|
|||||||
def test_select_1_ambiguity
|
def test_select_1_ambiguity
|
||||||
stream = stream_for "Hello\nWorld"
|
stream = stream_for "Hello\nWorld"
|
||||||
begin
|
begin
|
||||||
Timeout::timeout(3) do
|
Timeout::timeout(2) do
|
||||||
FZF.new(%w[--query=o --select-1], stream).start
|
FZF.new(%w[--query=o --select-1], stream).start
|
||||||
end
|
end
|
||||||
flunk 'Should not reach here'
|
flunk 'Should not reach here'
|
||||||
@ -681,5 +682,19 @@ class TestFZF < MiniTest::Unit::TestCase
|
|||||||
# **[***** #] => [******# ]
|
# **[***** #] => [******# ]
|
||||||
assert_equal [true, 0, 6], fzf.constrain(2, 10, 7, 10)
|
assert_equal [true, 0, 6], fzf.constrain(2, 10, 7, 10)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_invalid_utf8
|
||||||
|
tmp = Tempfile.new('fzf')
|
||||||
|
tmp << 'hello ' << [0xff].pack('C*') << ' world' << $/ << [0xff].pack('C*')
|
||||||
|
tmp.close
|
||||||
|
begin
|
||||||
|
Timeout::timeout(1) do
|
||||||
|
FZF.new(%w[-n..,1,2.. -q^ -x], File.open(tmp.path)).start
|
||||||
|
end
|
||||||
|
rescue Timeout::Error
|
||||||
|
end
|
||||||
|
ensure
|
||||||
|
tmp.unlink
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user