Sha256: a62398fea267830d63b04a2c79b8e16193e034d83d895e0235109829a0ec6fbb

Contents?: true

Size: 809 Bytes

Versions: 1

Compression:

Stored size: 809 Bytes

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_nil 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_nil 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 {
      assert reader.read_one_char
    }
    assert_nil reader.read_one_char
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bychar-3.0.0 test/test_strreader.rb