mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 08:33:58 +02:00
[rubygems/rubygems] Boundary check in Gem::StreamUI#choose_from_list
abacb0cb34
This commit is contained in:
parent
47c7c188e0
commit
f602cb55d7
2 changed files with 31 additions and 0 deletions
|
@ -114,6 +114,36 @@ class TestGemStreamUI < Gem::TestCase
|
|||
assert_equal "which one?\n 1. foo\n 2. bar\n> ", @out.string
|
||||
end
|
||||
|
||||
def test_choose_from_list_0
|
||||
@in.puts "0"
|
||||
@in.rewind
|
||||
|
||||
result = @sui.choose_from_list "which one?", %w[foo bar]
|
||||
|
||||
assert_equal [nil, nil], result
|
||||
assert_equal "which one?\n 1. foo\n 2. bar\n> ", @out.string
|
||||
end
|
||||
|
||||
def test_choose_from_list_over
|
||||
@in.puts "3"
|
||||
@in.rewind
|
||||
|
||||
result = @sui.choose_from_list "which one?", %w[foo bar]
|
||||
|
||||
assert_equal [nil, nil], result
|
||||
assert_equal "which one?\n 1. foo\n 2. bar\n> ", @out.string
|
||||
end
|
||||
|
||||
def test_choose_from_list_negative
|
||||
@in.puts "-1"
|
||||
@in.rewind
|
||||
|
||||
result = @sui.choose_from_list "which one?", %w[foo bar]
|
||||
|
||||
assert_equal [nil, nil], result
|
||||
assert_equal "which one?\n 1. foo\n 2. bar\n> ", @out.string
|
||||
end
|
||||
|
||||
def test_progress_reporter_silent_nil
|
||||
@cfg.verbose = nil
|
||||
reporter = @sui.progress_reporter 10, "hi"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue