Sha256: 519e8426a1a49676fb4ec8b26714ef453ca27da42e23899826f3f62438f2112c

Contents?: true

Size: 861 Bytes

Versions: 17

Compression:

Stored size: 861 Bytes

Contents

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

class TestBufferIO < Test::Unit::TestCase
  
  def test_write_in_mem_has_a_stringio
    io = Tracksperanto::BufferIO.new
    9000.times { io.write("a") }
    assert_kind_of StringIO, io.__getobj__
    assert_nothing_raised { io.close! }
  end
  
  def test_write_larger_than_max_swaps_tempfile
    io = Tracksperanto::BufferIO.new
    io.write("a" * 6_000_001)
    f = io.__getobj__
    assert_kind_of Tempfile, f
    f.rewind
    assert_equal 6_000_001, f.read.length
    flexmock(f).should_receive(:close!).once
    io.close!
  end
  
  def test_to_file_forces_immediate_promotion_to_file
    io = Tracksperanto::BufferIO.new
    io.write("a" * 3000)
    assert_equal 3000, io.pos
    assert !io.file_backed?
    
    f = io.to_file
    assert_equal 3000, f.pos
    assert f.file_backed?
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
tracksperanto-2.8.6 test/test_buffer_io.rb
tracksperanto-2.8.5 test/test_buffer_io.rb
tracksperanto-2.8.4 test/test_buffer_io.rb
tracksperanto-2.8.2 test/test_buffer_io.rb
tracksperanto-2.8.1 test/test_buffer_io.rb
tracksperanto-2.8.0 test/test_buffer_io.rb
tracksperanto-2.7.0 test/test_buffer_io.rb
tracksperanto-2.6.3 test/test_buffer_io.rb
tracksperanto-2.6.2 test/test_buffer_io.rb
tracksperanto-2.6.1 test/test_buffer_io.rb
tracksperanto-2.6.0 test/test_buffer_io.rb
tracksperanto-2.5.0 test/test_buffer_io.rb
tracksperanto-2.4.1 test/test_buffer_io.rb
tracksperanto-2.3.3 test/test_buffer_io.rb
tracksperanto-2.3.2 test/test_buffer_io.rb
tracksperanto-2.3.1 test/test_buffer_io.rb
tracksperanto-2.3.0 test/test_buffer_io.rb