<commit_before>require File.expand_path(File.dirname(__FILE__)) + '/helper'

class TestBufferingReader < Test::Unit::TestCase
  def test_reads_once
    s = StringIO.new("This is a string")
    
    reader = Tracksperanto::BufferingReader.new(s)
    assert_equal "T", reader.read_one_byte
    assert_equal "h", reader.read_one_byte
    assert !reader.eof?
  end
  
  def test_eof_with_empty
    s = StringIO.new
    reader = Tracksperanto::BufferingReader.new(s)
    assert s.eof?
  end
  
  def test_eof_with_io_at_eof
    s = StringIO.new("foo")
    s.read(3)
    reader = Tracksperanto::BufferingReader.new(s)
    assert reader.eof?
  end
  <commit_msg>Add more tests for buffer size<commit_after>require File.expand_path(File.dirname(__FILE__)) + '/helper'

class TestBufferingReader < Test::Unit::TestCase
  def test_reads_once
    s = StringIO.new("This is a string")
    
    reader = Tracksperanto::BufferingReader.new(s)
    assert_equal "T", reader.read_one_byte
    assert_equal "h", reader.read_one_byte
    assert !reader.eof?
  end
  
  def test_reads_set_buffer_size
    s = StringIO.new("abcd")
    flexmock(s).should_receive(:read).with(4).once.and_return("abcd")
    reader = Tracksperanto::BufferingReader.new(s, 4)
    reader.read_one_byte
  end
  
  def test_reads_in_10kb_chunks_by_default
    s = StringIO.new("abcd")
    flexmock(s).should_receive(:read).with(10240).once.and_return("abcd")
    reader = Tracksperanto::BufferingReader.new(s)
    reader.read_one_byte
  end
  
  def test_eof_with_empty
    s = StringIO.new
    reader = Tracksperanto::BufferingReader.new(s)
    assert s.eof?
  end
  
  def test_eof_with_io_at_eof
    s = StringIO.new("foo")
    s.read(3)
    reader = Tracksperanto::BufferingReader.new(s)
    assert reader.eof?
  end
  
{'fraction_non_alphanumeric': 0.10854893138357705, 'fraction_numerical': 0.006186726659167604, 'mean_word_length': 3.821138211382114, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7561880', 'n_tokens_mistral': 664, 'n_tokens_neox': 652, 'n_words': 110}