Sha256: 43d133337aab0f496fe1c0c4bdf648e57fa6e32b393b035347ead2af09b72743
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
require 'helper' require 'stringio' class TestStrReader < Test::Unit::TestCase def test_reads_once s = StringIO.new("This is a string") reader = Bychar::ReaderIOBuf.new(s) assert_equal "T", reader.read_one_char! assert_equal "h", reader.read_one_char! end def test_eof_with_empty s = StringIO.new reader = Bychar::ReaderStrbuf.new(s) assert_raise(Bychar::EOF) { reader.read_one_char! } end def test_eof_with_io_at_eof s = StringIO.new("foo") s.read(3) reader = Bychar::ReaderStrbuf.new(s) assert_raise(Bychar::EOF) { reader.read_one_char! } end def test_eof_with_string_to_size s = "Foobarboo another" s = StringIO.new(s) reader = Bychar::ReaderStrbuf.new(s) s.length.times { reader.read_one_char! } assert_raise(Bychar::EOF) { reader.read_one_char! } end def test_read_one_byte_and_raise_at_eof str = "Frobobo" bytes = [] assert_raise(Bychar::EOF) do s = Bychar::ReaderStrbuf.new(StringIO.new(str)) loop { bytes << s.read_one_char! } end assert_equal %w( F r o b o b o ), bytes end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bychar-2.0.0 | test/test_strreader.rb |