-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request puma#90 from dstrelau/nullio-read-fixes
Make NullIO#read mimic IO#read
- Loading branch information
Showing
2 changed files
with
34 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,31 @@ | |||
require 'puma/null_io' | |||
require 'test/unit' | |||
|
|||
class TestNullIO < Test::Unit::TestCase | |||
attr_accessor :nio | |||
def setup | |||
self.nio = Puma::NullIO.new | |||
end | |||
|
|||
def test_read_with_no_arguments | |||
assert_equal "", nio.read | |||
end | |||
|
|||
def test_read_with_nil_length | |||
assert_equal "", nio.read(nil) | |||
end | |||
|
|||
def test_read_with_zero_length | |||
assert_equal "", nio.read(0) | |||
end | |||
|
|||
def test_read_with_positive_integer_length | |||
assert_nil nio.read(1) | |||
end | |||
|
|||
def test_read_with_length_and_buffer | |||
buf = "" | |||
assert_nil nio.read(1,buf) | |||
assert_equal "", buf | |||
end | |||
end |