mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-12-22 19:09:00 +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
|
||||
def addstr_safe str
|
||||
C.addstr str.gsub("\0", '')
|
||||
str = str.gsub("\0", '') rescue str
|
||||
C.addstr str
|
||||
end
|
||||
|
||||
def print_input
|
||||
@ -1105,7 +1106,7 @@ class FZF
|
||||
begin
|
||||
unless @delim
|
||||
# AWK default
|
||||
prefix_length = (str.index(/\S/) rescue 0)|| 0
|
||||
prefix_length = (str.index(/\S/) || 0) rescue 0
|
||||
tokens = str.scan(/\S+\s*/) rescue []
|
||||
else
|
||||
prefix_length = 0
|
||||
|
@ -5,6 +5,7 @@ require 'curses'
|
||||
require 'timeout'
|
||||
require 'stringio'
|
||||
require 'minitest/autorun'
|
||||
require 'tempfile'
|
||||
$LOAD_PATH.unshift File.expand_path('../..', __FILE__)
|
||||
ENV['FZF_EXECUTABLE'] = '0'
|
||||
load 'fzf'
|
||||
@ -614,7 +615,7 @@ class TestFZF < MiniTest::Unit::TestCase
|
||||
def test_select_1_ambiguity
|
||||
stream = stream_for "Hello\nWorld"
|
||||
begin
|
||||
Timeout::timeout(3) do
|
||||
Timeout::timeout(2) do
|
||||
FZF.new(%w[--query=o --select-1], stream).start
|
||||
end
|
||||
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)
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user