2017-05-12 15:16:55 -04:00
|
|
|
require_relative "helper"
|
2012-08-12 00:42:46 -04:00
|
|
|
|
2016-11-22 10:05:49 -05:00
|
|
|
require "puma/io_buffer"
|
|
|
|
|
|
|
|
class TestIOBuffer < Minitest::Test
|
2012-08-12 00:42:46 -04:00
|
|
|
attr_accessor :iobuf
|
|
|
|
def setup
|
|
|
|
self.iobuf = Puma::IOBuffer.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_initial_size
|
2020-02-27 14:50:34 -05:00
|
|
|
assert_equal 0, iobuf.size
|
2012-08-12 00:42:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_append_op
|
2016-11-22 10:05:49 -05:00
|
|
|
iobuf << "abc"
|
2012-08-12 00:42:46 -04:00
|
|
|
assert_equal "abc", iobuf.to_s
|
|
|
|
iobuf << "123"
|
|
|
|
assert_equal "abc123", iobuf.to_s
|
2020-02-27 14:50:34 -05:00
|
|
|
assert_equal 6, iobuf.size
|
2012-08-12 00:42:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_append
|
|
|
|
expected = "mary had a little lamb"
|
|
|
|
iobuf.append("mary", " ", "had ", "a little", " lamb")
|
|
|
|
assert_equal expected, iobuf.to_s
|
2020-02-27 14:50:34 -05:00
|
|
|
assert_equal expected.length, iobuf.size
|
2012-08-12 00:42:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_reset
|
|
|
|
iobuf << "content"
|
|
|
|
assert_equal "content", iobuf.to_s
|
|
|
|
iobuf.reset
|
2020-02-27 14:50:34 -05:00
|
|
|
assert_equal 0, iobuf.size
|
2012-08-12 00:42:46 -04:00
|
|
|
assert_equal "", iobuf.to_s
|
|
|
|
end
|
|
|
|
end
|